https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117405
Bug ID: 117405 Summary: std::type_info::before() fails the asymmetry requirement Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: miki at keeperrl dot com Target Milestone: --- Created attachment 59517 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59517&action=edit Example program that can potentially produce wrong results. I encountered this bug when compiling using x86_64-w64-mingw32.shared-g++ in the mxe environment, while using std::set<std::type_index>. Looking closely at the code in libstdc++-v3/ libsupc++/tinfo2.cc, it's obvious that before() is not symmetric and can potentially give conflicting results for types where one type's mangled name starts with a '*', and the other one's doesn't, depending on the order of arguments. I've attached an example program showing the issue. Note that it requires specific circumstances to crash, i.e. both __GXX_TYPEINFO_EQUALITY_INLINE and __GXX_MERGED_TYPEINFO_NAMES set to 0. Even then, I observed one computer compiling it into an executable that doesn't crash, and another into one that crashes, presumably depending on how the mangled names are ordered in memory. I noticed that this implementation of type_info::before() was already discussed under another bug report, so if this wasn't fixed then maybe I'm missing something and perhaps my toolchain is misconfigured, in that case I'd appreciate any hints on that. This has major impact for me since my software will only work correctly when cross-compiled on an older machine that I don't use anymore.