gcc/libstdc++-v3/testsuite
Jonathan Wakely 0b3ec8f48f PR libstdc++/78420 Make std::less etc. yield total order for pointers
In order for std::less<T*> etc. to meet the total order requirements of
[comparisons] p2 we need to cast unrelated pointers to uintptr_t before
comparing them. Those casts aren't allowed in constant expressions, so
only cast when __builtin_constant_p says the result of the comparison is
not a compile-time constant (because the arguments are not constants, or
the result of the comparison is unspecified). When the result is
constant just compare the pointers directly without casting.

This ensures that the function can be called in constant expressions
with suitable arguments, but still yields a total order even for
otherwise unspecified pointer comparisons.

For std::less<void> etc. add new overloads for pointers, which use
std::less<common_type_t<T*,U*>> directly. Also change the generic
overloads to detect when the comparison would call a built-in relational
operator with pointer operands, and dispatch that case to the
corresponding specialization for void pointers.

	PR libstdc++/78420
	* include/bits/stl_function.h (greater<_Tp*>, less<_Tp*>)
	(greater_equal<_Tp*>, less_equal<_Tp>*): Add partial specializations
	to ensure total order for pointers.
	(greater<void>, less<void>, greater_equal<void>, less_equal<void>):
	Add operator() overloads for pointer arguments and make generic
	overloads dispatch to new _S_cmp functions when comparisons would
	use built-in operators for pointers.
	* testsuite/20_util/function_objects/comparisons_pointer.cc: New.

From-SVN: r258540
2018-03-14 23:02:01 +00:00
..
17_intro * testsuite/17_intro/names.cc: Undefine 'y' on SPARC/Linux. 2018-01-16 20:40:09 +00:00
18_support PR libstdc++/84773 use aligned alloc functions for FreeBSD and MinGW cross-compilers 2018-03-12 22:52:16 +00:00
19_diagnostics
20_util PR libstdc++/78420 Make std::less etc. yield total order for pointers 2018-03-14 23:02:01 +00:00
21_strings
22_locale
23_containers 2018-01-10 François Dumont <fdumont@gcc.gnu.org> 2018-01-10 16:59:02 +00:00
24_iterators
25_algorithms
26_numerics Remove duplicate "//" in comment 2018-01-29 14:09:52 +00:00
27_io Link with correct values-*.o files on Solaris (PR target/40411) 2018-01-12 09:52:53 +00:00
28_regex re PR libstdc++/83601 (std::regex_replace C++14 conformance issue: escaping in SED mode) 2018-01-14 00:48:30 +00:00
29_atomics
30_threads PR libstdc++/84532 prevent unwrapping of reference_wrapper arguments 2018-02-23 23:23:43 +00:00
abi
backward
config
data
decimal
experimental PR libstdc++/83626 handle ENOENT due to filesystem race 2018-01-05 18:02:18 +00:00
ext [libstdc++][testsuite] Fix dg-options/dg-add-options order 2018-01-19 11:17:34 +01:00
lib
libstdc++-abi
libstdc++-dg
libstdc++-prettyprinters printers.py (NodeIteratorPrinter): New. 2018-03-08 06:26:15 +00:00
libstdc++-xmethods
performance
special_functions [libstdc++][testsuite] Fix dg-options/dg-add-options order 2018-01-19 11:17:34 +01:00
tr1
tr2
util
Makefile.am
Makefile.in