https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113159
--- Comment #11 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- (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. Also saying a comparator (alone) is valid or invalid is not really meaningful. It's only valid or invalid with a given input. For example, less<double> may be valid or invalid depending on if your input contains NaN. Thus static analyzing will either produce many false positives or many false negatives.