libstdc++: Fix BUILTIN-PTR-CMP helpers
authorJonathan Wakely <jwakely@redhat.com>
Sun, 9 Feb 2020 13:37:43 +0000 (13:37 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Sun, 9 Feb 2020 13:37:43 +0000 (13:37 +0000)
commitdcda050e6c3c3726cb14109674053f83cae330be
tree57f505992990d92e97d0e99617c3f7cf7c7227b6
parent81958cd6adf402a85dc7d21b43caac56fba0af21
libstdc++: Fix BUILTIN-PTR-CMP helpers

The helpers that implement BUILTIN-PTR-CMP do not currently check if the
arguments are actually comparable, so the concept is true when it
shouldn't be.

Since we're trying to test for an unambiguous conversion to pointers, we
can also require that it returns bool, because the built-in comparisons
for pointers do return bool.

* include/bits/range_cmp.h (__detail::__eq_builtin_ptr_cmp): Require
equality comparison to be valid and return bool.
(__detail::__less_builtin_ptr_cmp): Likewise for less-than comparison.
* testsuite/20_util/function_objects/range.cmp/equal_to.cc: Check
type with ambiguous conversion to fundamental types.
* testsuite/20_util/function_objects/range.cmp/less.cc: Likewise.
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/range_cmp.h
libstdc++-v3/testsuite/20_util/function_objects/range.cmp/equal_to.cc
libstdc++-v3/testsuite/20_util/function_objects/range.cmp/less.cc