gcc/libstdc++-v3
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
..
config PR libstdc++/83834 replace wildcard pattern in linker script 2018-01-16 12:43:08 +00:00
doc Regenerate libstdc++ documentation 2018-01-29 12:37:17 +00:00
include PR libstdc++/78420 Make std::less etc. yield total order for pointers 2018-03-14 23:02:01 +00:00
libsupc++
po
python printers.py (build_libstdcxx_dictionary): Fix std::_Fwd_list_iterator and std::_Fwd_list_const_iterator printers registration. 2018-03-09 05:56:07 +00:00
scripts
src Use non-throwing is_directory in filesystem::create_directory 2018-03-09 01:09:58 +00:00
testsuite PR libstdc++/78420 Make std::less etc. yield total order for pointers 2018-03-14 23:02:01 +00:00
acinclude.m4
aclocal.m4
ChangeLog PR libstdc++/78420 Make std::less etc. yield total order for pointers 2018-03-14 23:02:01 +00:00
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
config.h.in configure.ac (AC_CHECK_HEADERS): Add linux/types.h. 2018-01-18 20:52:16 +01:00
configure PR libstdc++/84773 use aligned alloc functions for FreeBSD and MinGW cross-compilers 2018-03-12 22:52:16 +00:00
configure.ac PR libstdc++/81797 Add .NOTPARALLEL to include/Makefile for darwin 2018-02-15 20:56:41 +00:00
configure.host
crossconfig.m4 PR libstdc++/84773 use aligned alloc functions for FreeBSD and MinGW cross-compilers 2018-03-12 22:52:16 +00:00
fragment.am
linkage.m4
Makefile.am
Makefile.in
README

file: libstdc++-v3/README

New users may wish to point their web browsers to the file
index.html in the 'doc/html' subdirectory.  It contains brief
building instructions and notes on how to configure the library in
interesting ways.