https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113159
--- Comment #13 from Yury Gribov <ygribov at gcc dot gnu.org> --- (In reply to Xi Ruoyao from comment #11) > (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. > > It's not possible in general: doing so would require an O(n^3) runtime > checking. We may easily detect *some* invalid combinations of comparators > and inputs but it's different from what you want. Oh, I totally agree. I just tried to point out that changing std::sort to never ever crash on invalid comparator may not be best for all users.