[Bug libstdc++/93972] ranges::lexicographical_compare gives wrong answer for signed integers
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Feb 28 22:59:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93972
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:ce33801fe4c2272b31c64288b34c67a61529ce37
commit r10-6930-gce33801fe4c2272b31c64288b34c67a61529ce37
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Feb 28 14:16:06 2020 -0500
libstdc++: Fix bogus use of memcmp in ranges::lexicographical_compare (PR
93972)
We were enabling the memcmp optimization in ranges::lexicographical_compare
for
signed integral types and for integral types wider than a byte. But memcmp
gives the wrong answer for arrays of such types. This patch fixes this
issue by
refining the condition that enables the memcmp optimization. It's now
consistent with the corresponding condition used in
std::lexicographical_compare.
libstdc++-v3/ChangeLog:
PR libstdc++/93972
* include/bits/ranges_algo.h
(__lexicographical_compare_fn::operator()):
Fix condition for when to use memcmp, making it consistent with the
corresponding condition used in std::lexicographical_compare.
* testsuite/25_algorithms/lexicographical_compare/93972.cc: New test.
More information about the Gcc-bugs
mailing list