https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108674
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Roman Lebedev from comment #9) > (In reply to Jonathan Wakely from comment #7) > > (In reply to Roman Lebedev from comment #0) > > > I believe in the version 12, a new instance of such intentional wraparound > > > was introduced into libstdc++: https://godbolt.org/z/rq153fxKW > > > > No, that code is from 2014-12-19. > I agree that the _S_compare is rather old. > What i'm saying is that i have never seen this issue before v12, > so std::map implementation must have been refactored > to use the function in question, and that "introduced" the issue. Again no. A map of strings has always compared the strings, and that has always used that function. Your godbolt example has exactly the same behaviour with GCC 7 (I didn't bother testing anything older): tmp$ cat wrap.cc #include <string> #include <map> enum class BitOrder { LSB, /* Memory order */ MSB, /* Input is added to stack byte by byte, and output is lifted from top */ MSB16, /* Same as above, but 16 bits at the time */ MSB32, /* Same as above, but 32 bits at the time */ }; const std::map<std::string, BitOrder, std::less<>> order2enum = { {"plain", BitOrder::LSB}, {"jpeg", BitOrder::MSB}, {"jpeg16", BitOrder::MSB16}, {"jpeg32", BitOrder::MSB32}, }; int main() { return order2enum.find("plain") == order2enum.end(); } tmp$ clang++ --gcc-toolchain=$HOME/gcc/7 wrap.cc -O3 -fsanitize=unsigned-integer-overflow tmp$ ./a.out /home/jwakely/gcc/7/lib/gcc/x86_64-pc-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/basic_string.h:392:51: runtime error: unsigned integer overflow: 4 - 6 cannot be represented in type 'unsigned long' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/jwakely/gcc/7/lib/gcc/x86_64-pc-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/basic_string.h:392:51 in