https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100795
--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:92417c387365033cac4fff7ec8da2b42bd75dfba commit r16-1741-g92417c387365033cac4fff7ec8da2b42bd75dfba Author: Patrick Palka <ppa...@redhat.com> Date: Fri Jun 27 13:53:06 2025 -0400 libstdc++: Directly implement ranges::sort [PR100795] As with the previous patch, this patch reimplements ranges::sort directly instead of incorrectly forwarding to std::sort. In addition to the compatibility changes listed in the previous patch we also: - use ranges::iter_swap instead of std::iter_swap - use ranges::move_backward instead of std::move_backward - use __bit_width and __to_unsigned_like instead of __lg PR libstdc++/100795 PR libstdc++/118209 libstdc++-v3/ChangeLog: * include/bits/max_size_type.h (__bit_width): New explicit specialization for __max_size_type. * include/bits/ranges_algo.h (__detail::__move_median_to_first): New, based on the stl_algo.h implementation. (__detail::__unguarded_liner_insert): Likewise. (__detail::__insertion_sort): Likewise. (__detail::__sort_threshold): Likewise. (__detail::__unguarded_insertion_sort): Likewise. (__detail::__final_insertion_sort): Likewise. (__detail::__unguarded_partition): Likewise. (__detail::__unguarded_partition_pivot): Likewise. (__detail::__heap_select): Likewise. (__detail::__partial_sort): Likewise. (__detail::__introsort_loop): Likewise. (__sort_fn::operator()): Reimplement in terms of the above. * testsuite/25_algorithms/sort/118209.cc: New test. * testsuite/25_algorithms/sort/constrained.cc (test03): New test. Reviewed-by: Tomasz KamiÅski <tkami...@redhat.com> Reviewed-by: Jonathan Wakely <jwak...@redhat.com>