]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix conditions for using memcmp in std::lexicographical_compare_three_way...
authorJonathan Wakely <jwakely@redhat.com>
Tue, 27 Feb 2024 17:50:34 +0000 (17:50 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 18 Mar 2024 13:50:53 +0000 (13:50 +0000)
commit6f5dcea85a31845ec6f4b6886734b0f02e013718
tree4fd4b92a8490268ca09e150e8790f4295a4fcf0e
parent8ec265c1464dec74f98e6914cd164af5090a39ff
libstdc++: Fix conditions for using memcmp in std::lexicographical_compare_three_way [PR113960]

The change in r11-2981-g2f983fa69005b6 meant that
std::lexicographical_compare_three_way started to use memcmp for
unsigned integers on big endian targets, but for that to be valid we
need the two value types to have the same size and we need to use that
size to compute the length passed to memcmp.

I already defined a __is_memcmp_ordered_with trait that does the right
checks, std::lexicographical_compare_three_way just needs to use it.

libstdc++-v3/ChangeLog:

PR libstdc++/113960
* include/bits/stl_algobase.h (__is_byte_iter): Replace with ...
(__memcmp_ordered_with): New concept.
(lexicographical_compare_three_way): Use __memcmp_ordered_with
instead of __is_byte_iter. Use correct length for memcmp.
* testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc:
New test.

(cherry picked from commit f5cdda8acb06c20335855ed353ab9a441c12128a)
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc [new file with mode: 0644]
This page took 0.072876 seconds and 6 git commands to generate.