public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/103240] std::type_info::before gives wrong answer for ARM EABI Date: Thu, 04 May 2023 11:04:35 +0000 [thread overview] Message-ID: <bug-103240-4-LZC7t424uO@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103240-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103240 --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to frankhb1989 from comment #7) > (In reply to Jonathan Wakely from comment #6) > > > What are the mangled type names that are unordered? (that's all you need to > > describe, everything about flat_map and partition_point is irrelevant; just > > tell us which names are unordered). > > Here are the pair of the unordered names in the actual case: > > 1. > St5_BindIFPFN3NPL15ReductionStatusERNS0_8TermNodeERNS0_11ContextNodeEESt17ref > erence_wrapperIS2_ESt12_PlaceholderILi1EEEE > 2. > St5_BindIFZN3NPL2A112_GLOBAL__N_113DoDefineOrSetILb0EE4CallIJEEENS0_15Reducti > onStatusERNS0_8TermNodeERNS0_11ContextNodeESt10shared_ptrINS0_11EnvironmentEE > S8_DpOT_EUlRKS7_RKSD_E_S7_SD_EE Thanks. This second one has "*St5_BindIFZN3NPL..." in type_info::__name, so yes, they'll be incorrectly ordered with the out-of-line definition. t1.before(t2) will do a string comparison, but t2.before(t1) will do a pointer comparison and depend on the string table layout. > The unordered pair occurs iff. __GXX_TYPEINFO_EQUALITY_INLINE == 0, i.e. the > out-of-line definition is used, and regardless to the value of > __GXX_MERGED_TYPEINFO_NAMES (either 0 or 1). I don't think that's true. If __GXX_MERGED_TYPEINFO_NAMES is true then the out-of-line definition is correct. You can't just redefine that macro to 1 in your code and expect it to affect the out-of-line definition in the library. Even if you recompile the library with -D__GXX_MERGED_TYPEINFO_NAMES=1 that doesn't magically make it true. If the platform ABI and compiler and linker really do guarantee that all typeinfo names are unique, then address comparison works correctly. The problem case is when both __GXX_MERGED_TYPEINFO_NAMES and __GXX_TYPEINFO_EQUALITY_INLINE are zero. > As above, I've later tested all 4 combinations for sure. You can't expect that to give meaningful results though, you would need to rebuild the entire compiler for meaningful results with redefined macros, and even then it would fail when you use RTTI across dynamic library boundaries. You can't just redefine those macros and expect the compiler and OS to change how they work. > Accidentally the > inline definition of std::type_info::before does the right thing I don't think it's an accident. > (hopefully), so __GXX_TYPEINFO_EQUALITY_INLINE == 1 just works. Otherwise > there would be no easy workaround without the modification on the standard > headers. > > Forcing address comparisons is wrong in general, but with some additional > assumptions to rule out all potential offending features, then all type_info > objects follow ODR in the strict sense, so this just works. When this is an > issue, __GXX_TYPEINFO_EQUALITY_INLINE == 1 && __GXX_MERGED_TYPEINFO_NAMES == > 0 should be safe for all names not from unnamed namespaces. This is a real > problem for MinGW (at least with GNU ld which does not perform ICF on > PE/COFF AFAIK), where __GXX_TYPEINFO_EQUALITY_INLINE == 1 && > __GXX_MERGED_TYPEINFO_NAMES == 1 causes something like > &typeid(shared_ptr<...>) not unique across module boundaries, and my code > fails elsewhere due to this reason. So stop redefining those macros then, you're lying to the compiler. __GXX_MERGED_TYPEINFO_NAMES=1 is a lie on your target. Don't do that.
next prev parent reply other threads:[~2023-05-04 11:04 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-15 0:20 [Bug libstdc++/103240] New: " redi at gcc dot gnu.org 2021-11-15 0:21 ` [Bug libstdc++/103240] " redi at gcc dot gnu.org 2021-11-15 0:36 ` redi at gcc dot gnu.org 2021-11-17 17:22 ` cvs-commit at gcc dot gnu.org 2021-11-17 17:42 ` redi at gcc dot gnu.org 2021-11-23 21:17 ` cvs-commit at gcc dot gnu.org 2023-04-29 16:15 ` frankhb1989 at gmail dot com 2023-04-29 18:01 ` frankhb1989 at gmail dot com 2023-05-02 16:56 ` redi at gcc dot gnu.org 2023-05-04 10:31 ` frankhb1989 at gmail dot com 2023-05-04 11:04 ` redi at gcc dot gnu.org [this message] 2023-05-05 16:28 ` frankhb1989 at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-103240-4-LZC7t424uO@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).