https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113159
--- Comment #19 from Yury Gribov <ygribov at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #17) > (In reply to Yury Gribov from comment #10) > > As a compiler user I would actually love my STL to crash fast on invalid > > comparators rather than produce unpredictable and meaningless results which > > will cause my program to misbehave later on in ways which are much harder to > > debug. > > That's what _GLIBCXX_DEBUG and/or _GLIBCXX_ASSERTIONS are for. I'm not sure they solve the issue - AFAIK this macro only enables irreflexivity checks so asymmetry/transitivity violations will go undetected. (BTW libc++ LIBCXX_ENABLE_DEBUG_MODE is slightly more aggressive as it checks for asymmetry as well, see https://releases.llvm.org/15.0.0/projects/libcxx/docs/DesignDocs/DebugMode.html#id2) In general, why avoiding std::sort crashes is considered a good thing? Wouldn't we just hide the error and produce invalid results causing harder to debug errors later in user's program?