LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 45549 - std::type_index equality broken with LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT=OFF
Summary: std::type_index equality broken with LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT...
Status: RESOLVED FIXED
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: 9.0
Hardware: All All
: P normal
Assignee: Louis Dionne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-15 05:26 PDT by Ryan Brown
Modified: 2021-01-26 06:23 PST (History)
6 users (show)

See Also:
Fixed By Commit(s): 2464d8135e2a


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Brown 2020-04-15 05:26:13 PDT
When using LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT=OFF, distinct classes with the same name, each in a different TU and anonymous namespace, are considered equal by std::type_index.

LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT=OFF is used in the libc++ shipped with Xcode as of Xcode 11.4. The bug does not occur in Xcode 11.3.1, the previous version. LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT was introduced in 2405bd689 for LLVM 9.0.0.

See https://gist.github.com/ryb-ableton/1805b61e2d0976de4ba04c2aa2f5992b for a minimal test case.

May be related to https://bugs.llvm.org/show_bug.cgi?id=34907

----------------

Steps to reproduce on Linux/x86:

  1. Build and install libc++ 9.0 or 10.0 by passing -DLIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT=OFF to cmake
  2. Download and extract a zip of the Gist linked above
  3. Run "bash ./build_and_run"

Steps to reproduce on macOS:

  1. Install and select Xcode 11.4, which uses LIBCXX_HAS_MERGED_TYPEINFO_NAMES_DEFAULT=OFF by default
  2. Download and extract a zip of the Gist linked above
  3. Run "bash ./build_and_run"

Actual Output:

  Assertion failed: (registry[0] != registry[1]), function main, file main.cpp, line 13.
  ./run: line 4: 39942 Abort trap: 6           ./test
  Failure

Expected Output:

  Success
Comment 1 Louis Dionne 2020-04-27 13:24:35 PDT
Thanks for the report and the nice analysis of the issue!

I fixed the issue on Apple platforms in 2464d8135e2a, and I'm adding tests so we don't regress in https://reviews.llvm.org/D78963.
Comment 2 Ryan Brown 2020-04-28 05:02:31 PDT
Nice, thanks for the quick fix!