https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111499
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |12.5 Keywords| |missed-optimization --- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Adding a quick calls to size to operator<=> in bits/stl_vector.h fixes the warning and we get just a return 0 for this code. This adds that the diff end()-begin() for both __x and __y are known to be greater than equal to 0. Like this: template<typename _Tp, typename _Alloc> [[nodiscard]] constexpr __detail::__synth3way_t<_Tp> operator<=>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { (void)__x.size(); (void)__y.size(); return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __detail::__synth3way); } Since we know that in this case begin will always be before end. Though I wonder if that knowledge should be pused down to std::lexicographical_compare_three_way instead ...