Go to file
Jonathan Wakely 2f983fa690 libstdc++: Fix three-way comparison for std::array [PR 96851]
The spaceship operator for std::array uses memcmp when the
__is_byte<value_type> trait is true, but memcmp isn't usable in
constexpr contexts. Also, memcmp should only be used for unsigned byte
types, because it gives the wrong answer for signed chars with negative
values.

We can simply check std::is_constant_evaluated() so that we don't use
memcmp during constant evaluation.

To fix the problem of using memcmp for inappropriate types, this patch
adds new __is_memcmp_ordered and __is_memcmp_ordered_with traits. These
say whether using memcmp will give the right answer for ordering
operations such as lexicographical_compare and three-way comparisons.
The new traits can be used in several places, and can also be used to
implement my suggestion in PR 93059 comment 37 to use memcmp for
unsigned integers larger than one byte on big endian targets.

libstdc++-v3/ChangeLog:

	PR libstdc++/96851
	* include/bits/cpp_type_traits.h (__is_memcmp_ordered):
	New trait that says if memcmp can be used for ordering.
	(__is_memcmp_ordered_with): Likewise, for two types.
	* include/bits/deque.tcc (__lex_cmp_dit): Use new traits
	instead of __is_byte and __numeric_traits.
	(__lexicographical_compare_aux1): Likewise.
	* include/bits/ranges_algo.h (__lexicographical_compare_fn):
	Likewise.
	* include/bits/stl_algobase.h (__lexicographical_compare_aux1)
	(__is_byte_iter): Likewise.
	* include/std/array (operator<=>): Likewise. Only use memcmp
	when std::is_constant_evaluated() is false.
	* testsuite/23_containers/array/comparison_operators/96851.cc:
	New test.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
2020-09-02 15:32:11 +01:00
config
contrib Daily bump. 2020-08-27 00:16:27 +00:00
fixincludes
gcc MSP430: Skip gcc.dg/pr55940.c in the small memory model 2020-09-02 14:18:09 +01:00
gnattools
gotools
include
INSTALL
intl
libada
libatomic
libbacktrace
libcc1
libcpp
libdecnumber
libffi
libgcc Daily bump. 2020-08-27 00:16:27 +00:00
libgfortran
libgo gotest: use a space rather than a middle dot in target lists 2020-08-27 16:18:01 -07:00
libgomp
libhsail-rt
libiberty Daily bump. 2020-08-27 00:16:27 +00:00
libitm
libobjc
liboffloadmic
libphobos
libquadmath
libsanitizer
libssp
libstdc++-v3 libstdc++: Fix three-way comparison for std::array [PR 96851] 2020-09-02 15:32:11 +01:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2020-08-27 00:16:27 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS MAINTAINERS: Add myself as OpenACC maintainer 2020-08-26 17:58:22 +02:00
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.