diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h --- a/libcxx/include/__algorithm/sort.h +++ b/libcxx/include/__algorithm/sort.h @@ -737,7 +737,10 @@ } // Use insertion sort if the length of the range is below the specified limit. if (__len < __limit) { - if (__leftmost) { + // TODO: Invalid comparison predicates can cause __insertion_sort_unguarded to go out-of-bounds, which is + // highly undesirable. Disable this optimization until we at least have a way to assert that we're + // not going out of bounds. + if (__leftmost || true) { std::__insertion_sort<_AlgPolicy, _Compare>(__first, __last, __comp); } else { std::__insertion_sort_unguarded<_AlgPolicy, _Compare>(__first, __last, __comp);