libstdc++: Fix std::lexicographic_compare for unsigned char (PR 93972)
authorJonathan Wakely <jwakely@redhat.com>
Mon, 2 Mar 2020 17:03:28 +0000 (17:03 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 2 Mar 2020 17:03:28 +0000 (17:03 +0000)
commitd112e173ea093f55a16a14b26ef65088381ee09c
tree0e431eed743ba1cc0e82d88a7b3fcc79b66d8b1f
parent4c391563407aeba981f6a71423297f36d5ece0ee
libstdc++: Fix std::lexicographic_compare for unsigned char (PR 93972)

The new 25_algorithms/lexicographical_compare/93972.cc test fails on
targets where char is unsigned, revealing an existing regression with
the std::__memcmp helper that had gone unnoticed in
std::lexicographical_compare. When comparing char and unsigned char, the
memcmp optimisation is enabled, but the new std::__memcmp function fails
to compile for mismatched types.

PR libstdc++/93972
* include/bits/stl_algobase.h (__memcmp): Allow pointer types to
differ.
* testsuite/25_algorithms/lexicographical_compare/uchar.cc: New test.
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/uchar.cc [new file with mode: 0644]