Commit Graph

12314 Commits

Author SHA1 Message Date
Jonathan Wakely
f5feee6adc libstdc++: Regenerate autoconf files
I forgot to regenerate these files in r11-6137.

libstdc++-v3/ChangeLog:

	* config.h.in: Regenerate.
	* configure: Regenerate.
2020-12-17 14:02:59 +00:00
GCC Administrator
eefe499fdf Daily bump. 2020-12-17 00:16:37 +00:00
Jonathan Wakely
7c1e7eed89 libstdc++: Add C++ runtime support for new 128-bit long double format
This adds support for the new __ieee128 long double format on
powerpc64le targets.

Most of the complexity comes from wanting a single libstdc++.so library
that contains the symbols needed by code compiled with both
-mabi=ibmlongdouble and -mabi=ieeelongdouble (and not forgetting
-mlong-double-64 as well!)

In a few places this just requires an extra overload, for example
std::from_chars has to be overloaded for both forms of long double.
That can be done in a single translation unit that defines overloads
for 'long double' and also '__ieee128', so that user code including
<charconv> will be able to link to a definition for either type of long
double. Those are the easy cases.

The difficult parts are (as for the std::string ABI transition) the I/O
and locale facets. In order to be able to write either form of long
double to an ostream such as std::cout we need the locale to contain a
std::num_put facet that can handle both forms. The same approach is
taken as was already done for supporting 64-bit long double and 128-bit
long double: adding extra overloads of do_put to the facet class. On
targets where the new long double code is enabled, the facets that are
registered in the locale at program startup have additional overloads so
that they can work with any long double type. Where this fails to work
is if user code installs its own facet, which will probably not have the
additional overloads and so will only be able to output one or the other
type. In practice the number of users expecting to be able to use their
own locale facets in code using a mix of -mabi=ibmlongdouble and
-mabi=ieeelongdouble is probably close to zero.

libstdc++-v3/ChangeLog:

	* Makefile.in: Regenerate.
	* config.h.in: Regenerate.
	* config/abi/pre/gnu.ver: Make patterns less greedy.
	* config/os/gnu-linux/ldbl-ieee128-extra.ver: New file with patterns
	for IEEE128 long double symbols.
	* configure: Regenerate.
	* configure.ac: Enable alternative 128-bit long double format on
	powerpc64*-*-linux*.
	* doc/Makefile.in: Regenerate.
	* fragment.am: Regenerate.
	* include/Makefile.am: Set _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT.
	* include/Makefile.in: Regenerate.
	* include/bits/c++config: Define inline namespace for new long
	double symbols. Don't define _GLIBCXX_USE_FLOAT128 when it's the
	same type as long double.
	* include/bits/locale_classes.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT]
	(locale::_Impl::_M_init_extra_ldbl128): Declare new member function.
	* include/bits/locale_facets.h (_GLIBCXX_NUM_FACETS): Simplify by
	only counting narrow character facets.
	(_GLIBCXX_NUM_CXX11_FACETS): Likewise.
	(_GLIBCXX_NUM_LBDL_ALT128_FACETS): New.
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT] (num_get::__do_get): Define
	vtable placeholder for __ibm128 long double type.
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(num_get::__do_get): Declare vtable placeholder for __ibm128 long
	double type.
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(num_put::__do_put): Likewise.
	* include/bits/locale_facets.tcc
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(num_get::__do_get, num_put::__do_put): Define.
	* include/bits/locale_facets_nonio.h
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(money_get::__do_get): Declare vtable placeholder for __ibm128 long
	double type.
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(money_put::__do_put): Likewise.
	* include/bits/locale_facets_nonio.tcc
	[_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && __LONG_DOUBLE_IEEE128__]
	(money_get::__do_get, money_put::__do_put): Define.
	* include/ext/numeric_traits.h [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT]
	(__numeric_traits<__ibm128>, __numeric_traits<__ieee128>): Define.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.am: Add compatibility-ldbl-alt128.cc and
	compatibility-ldbl-alt128-cxx11.cc sources and recipes for objects.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++11/compatibility-ldbl-alt128-cxx11.cc: New file defining
	symbols using the old 128-bit long double format, for the cxx11 ABI.
	* src/c++11/compatibility-ldbl-alt128.cc: Likewise, for the
	gcc4-compatible ABI.
	* src/c++11/compatibility-ldbl-facets-aliases.h: New header for long
	double compat aliases.
	* src/c++11/cow-locale_init.cc: Add comment.
	* src/c++11/cxx11-locale-inst.cc: Define C and C_is_char
	unconditionally.
	* src/c++11/cxx11-wlocale-inst.cc: Add sanity check. Include
	locale-inst.cc directly, not via cxx11-locale-inst.cc.
	* src/c++11/locale-inst-monetary.h: New header for monetary
	category instantiations.
	* src/c++11/locale-inst-numeric.h: New header for numeric category
	instantiations.
	* src/c++11/locale-inst.cc: Include new headers for monetary,
	numeric, and long double definitions.
	* src/c++11/wlocale-inst.cc: Remove long double compat aliases that
	are defined in new header now.
	* src/c++17/Makefile.am: Use -mabi=ibmlongdouble for
	floating_from_chars.cc.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/floating_from_chars.cc (from_chars_impl): Add
	if-constexpr branch for __ieee128.
	(from_chars): Overload for __ieee128.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/c++98/locale_init.cc (num_facets): Adjust calculation.
	(locale::_Impl::_Impl(size_t)): Call _M_init_extra_ldbl128.
	* src/c++98/localename.cc (num_facets): Adjust calculation.
	(locale::_Impl::_Impl(const char*, size_t)): Call
	_M_init_extra_ldbl128.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/util/testsuite_abi.cc: Add new symbol versions.
	Allow new symbols to be added to GLIBCXX_IEEE128_3.4.29 and
	CXXABI_IEEE128_1.3.13 too.
	* testsuite/26_numerics/complex/abi_tag.cc: Add u9__ieee128 to
	regex matching expected symbols.
2020-12-16 23:25:01 +00:00
Jonathan Wakely
4d4f82959a libstdc++: Simplify built-in detection in <utility>
Now that GCC supports __has_builtin there is no need to test whether
it's defined, we can just use it unconditionally.

libstdc++-v3/ChangeLog:

	* include/std/utility: Use __has_builtin without checking if
	it's defined.
2020-12-16 19:25:09 +00:00
Jonathan Wakely
767537a8b0 libstdc++: Warn if __STRICT_ANSI has been undefined
Recent changes to use __int128 as an integer-like type in <ranges> and
to optimize std::uniform_int_distribution mean that the library relies
on __int128 more heavily than in the past.

The library expects that if __int128 is supported then either
__GLIBCXX_TYPE_INT_N_0 is defined (and we treat is like the standard
integer types), or __STRICT_ANSI__ is defined (and we need to add
special handling for __int128 as a non-standard integer type).

If users compile with -std=c++NN -U__STRICT_ANSI__ then it puts the
library into a broken and inconsistent state, where the compiler doesn't
define the __GLIBCXX_TYPE_INT_N_0 macro, but the library thinks it
doesn't need special handling for __int128. What the user should do is
compile with -std=gnu++NN instead.

This adds a warning if it appears that __int128 is supported but neither
__GLIBCXX_TYPE_INT_N_0 nor __STRICT_ANSI__ is defined.

libstdc++-v3/ChangeLog:

	* include/bits/c++config: Warn if __STRICT_ANSI__ state is
	inconsistent with __GLIBCXX_TYPE_INT_N_0.
2020-12-16 19:25:09 +00:00
Jonathan Wakely
96d9670e88 libstdc++: Only use __builtin_sprintf if supported [PR 96083]
Clang doesn't support __builtin_sprintf, so use std::sprintf instead.

libstdc++-v3/ChangeLog:

	PR libstdc++/96083
	* include/ext/throw_allocator.h: Use __has_builtin to check for
	__builtin_sprintf support, and use std::sprtinf if necessary.
2020-12-16 14:33:26 +00:00
Jonathan Wakely
ab9bd93271 libstdc++: Fix errors from Library Fundamentals TS headers in C++11 [PR 98319]
Currently the <experimental/random>, <experimental/source_location> and
<experimental/utility> headers can be included in C++98 and C++11 modes,
but gives errors. With this change they can be included, but define
nothing.

libstdc++-v3/ChangeLog:

	PR libstdc++/98319
	* include/experimental/random: Only define contents for C++14
	and later.
	* include/experimental/source_location: Likewise.
	* include/experimental/utility: Likewise.
	* testsuite/experimental/feat-lib-fund.cc: Include all LFTS
	headers that are present. Allow test to run for all modes.
2020-12-16 13:37:17 +00:00
Jonathan Wakely
3cee0c6562 libstdc++: Add performance test for atomic_flag [PR 46447]
This adds a test to compare the performance of std::atomic_flag with
similar operations on std::atomic_uchar and std::atomic_int.

libstdc++-v3/ChangeLog:

	PR libstdc++/46447
	* testsuite/performance/29_atomics/atomic_flag.cc: New test.
2020-12-16 13:36:02 +00:00
Jonathan Wakely
a2c2eec183 libstdc++: Test errno macros directly, not via autoconf [PR 93151]
This fixes a bug caused by a mismatch between the macros defined by
<errno.h> when GCC is built and the macros defined by <errno.h> when
users include <system_error>. If the user code is compiled with
_XOPEN_SOURCE defined to 500 or 600, Darwin suppresses the
ENOTRECOVERABLE and EOWNERDEAD macros, which are not defined by SUSv3
(aka POSIX.1-2001).

Since POSIX requires the errno macros to be macros (and not variables or
enumerators) we can just test for them directly using the preprocessor.
That means that <system_error> will match what is actuallydefined when
it's included, not what was defined when GCC was built. With that change
there is no need for the GLIBCXX_CHECK_SYSTEM_ERROR configure checks and
they can be removed.

libstdc++-v3/ChangeLog:

	PR libstdc++/93151
	* acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): Remove.
	* configure.ac: Regenerate.
	* config/os/generic/error_constants.h: Test POSIX errno macros
	directly, instead of corresponding _GLIBCXX_HAVE_EXXX macros.
	* testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc:
	Likewise.
	* testsuite/19_diagnostics/headers/system_error/93151.cc: New
	test.
2020-12-16 13:36:02 +00:00
GCC Administrator
6e9d865119 Daily bump. 2020-12-16 00:16:31 +00:00
Jonathan Wakely
433703843b libstdc++: Remove init_priority attribute for Init object [PR 98108]
This reverts commit cf4ed3b415.

libstdc++-v3/ChangeLog:

    PR libstdc++/98108
    * include/std/iostream (__ioinit): Remove init_priority attribute.
2020-12-15 18:40:28 +00:00
Keith Packard
75aee07269 libstdc++: Support libc with stdio-only I/O in libstdc++
The current libstdc++ basic_file_stdio.cc code assumes a POSIX API
underneath the stdio implementation provided by the host libc. This
means that the host must provide a fairly broad POSIX file API,
including read, write, open, close, lseek and ioctl.

This patch changes basic_file_stdio.cc to only use basic ANSI-C stdio
functions, allowing it to be used with libc implementations like
picolibc which may not have a POSIX operating system underneath.

This is enabled by a new --enable-cstdio=stdio_pure configure option.

Aided-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_CSTDIO): Allow "stdio_pure"
	option and define _GLIBCXX_USE_PURE_STDIO when it is used. Also
	add "stdio_posix" option as an alias for "stdio".
	* config/io/basic_file_stdio.cc [_GLIBCXX_USE_PURE_STDIO]: Only
	use defined stdio entry points for all I/O operations, without
	direct calls to underlying POSIX functions.
	* config.h.in: Regenerate.
	* configure: Regenerate.
2020-12-15 17:39:24 +00:00
Ville Voutilainen
4e096e0ff8 libstdc++: Fix the test for rvalue stream extraction
libstdc++-v3/ChangeLog:

	* testsuite/27_io/rvalue_streams.cc: Run the extraction to a char*
	for C++17 and lower only.
2020-12-15 18:03:43 +02:00
Jonathan Wakely
e831ad4dab libstdc++: Increase timeout for tests in debug mode
These tests FAIL when testing debug mode with a small tool_timeout
value. Give them a longer relative timeout.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc:
	Add dg-timeout-factor directive.
	* testsuite/ext/pb_ds/regression/tree_map_rand_debug.cc:
	Increase timeout factor from 2.0 to 3.0.
	* testsuite/ext/pb_ds/regression/tree_set_rand_debug.cc:
	Likewise.
	* testsuite/lib/libstdc++.exp (check_effective_target_debug-mode):
	Define "debug-mode" as an effective-target keyword.
2020-12-15 15:39:58 +00:00
Jonathan Wakely
f072d1021e libstdc++: Do not define constexpr assertions for C++11
There's no point even checking is_constant_evaluated() in C++11 mode,
because the 'if' statement used for the assertion wouldn't be valid in a
C++11 constexpr function anyway.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (__glibcxx_assert_1): Define as empty
	for C++11.
2020-12-15 15:39:58 +00:00
Marius Hillenbrand
7640db5711 libstdc++: Fix required locales of a testcase
The testsuite for libstdc++ aims to skips test cases for which not all
required locales are installed. This patch adds missing directives about
required locales to one test case to avoid false positive test failures
on systems that have a partial set of locales installed.

Verified by test suite runs that this patch changes the test case from
FAIL to UNSUPPORTED when not all required locales are available and that
the test case will run and PASS when the necessary locales have been
added.

libstdc++-v3/ChangeLog:

	* testsuite/22_locale/locale/cons/5.cc: Add missing directives
	for required locales.
2020-12-15 11:45:27 +00:00
Jonathan Wakely
fa452a843d libstdc++: Remove workaround for PR c++/78173
Now that the G++ bug is fixed we no longer need to protect this partial
specialization from complaining about subtracting void pointers.

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (incrementable_traits<Tp>):
	Remove workaround for PR c++/78173.
2020-12-15 11:45:27 +00:00
Vladimir Vishnevsky
a929b39aa3 libstdc++: Disabling AC_LIBTOOL_DLOPEN check if building with avr-libc
The AC_LIBTOOL_DLOPEN checks were previously disabled for newlib targets.
The patch applies similar logic to avr-libc based builds.

libstdc++-v3/ChangeLog:

	* configure.ac: Skip AC_LIBTOOL_DLOPEN check if avr-libc is used.
	* configure: Regenerate.
2020-12-15 11:45:26 +00:00
Jonathan Wakely
cf4ed3b415 libstdc++: Use init_priority attribute for Init object [PR 98108]
This causes the global objects that run the <iostream> initialization
code to be constructed earlier, which avoids some bugs in user code due
to incorrectly relying on static initialization order.

libstdc++-v3/ChangeLog:

	PR libstdc++/98108
	* include/std/iostream (__ioinit): Add init_priority attribute.
2020-12-15 11:45:26 +00:00
Gerald Pfeifer
23900be4d3 libstdc++: Update link to Unicode-HOWTO
libstdc++-v3/ChangeLog:

2020-12-15  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/codecvt.xml: Update link to Unicode-HOWTO.
	* doc/html/manual/facets.html: Regenerate.
2020-12-15 09:33:18 +01:00
GCC Administrator
d52945ce54 Daily bump. 2020-12-15 00:16:35 +00:00
François Dumont
4c275e83dd libstdc++: Make tests with Undefined Behavior in C++11 UNSUPPORTED
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/array/debug/back1_neg.cc: Target c++14 because assertion
	is disabled in C++11.
	* testsuite/23_containers/array/debug/front1_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc: Likewise.
2020-12-14 22:28:38 +01:00
Martin Sebor
fe7f75cf16 Correct/improve maybe_emit_free_warning (PR middle-end/98166, PR c++/57111, PR middle-end/98160).
Resolves:
PR middle-end/98166 - bogus -Wmismatched-dealloc on user-defined allocator and inlining
PR c++/57111 - 57111 - Generalize -Wfree-nonheap-object to delete
PR middle-end/98160 - ICE in default_tree_printer at gcc/tree-diagnostic.c:270

gcc/ChangeLog:

	PR middle-end/98166
	PR c++/57111
	PR middle-end/98160
	* builtins.c (check_access): Call tree_inlined_location
	fndecl_alloc_p): Handle BUILT_IN_ALIGNED_ALLOC and
	BUILT_IN_GOMP_ALLOC.
	call_dealloc_p): Remove unused function.
	(new_delete_mismatch_p): Call valid_new_delete_pair_p and rework.
	(matching_alloc_calls_p): Handle built-in deallocation functions.
	(warn_dealloc_offset): Corrct the handling of user-defined operators
	delete.
	(maybe_emit_free_warning): Avoid assuming expression is a decl.
	Simplify.
	* doc/extend.texi (attribute malloc): Update.
	* tree-ssa-dce.c (valid_new_delete_pair_p): Factor code out into
	valid_new_delete_pair_p in tree.c.
	* tree.c (tree_inlined_location): Define new function.
	(valid_new_delete_pair_p): Define.
	* tree.h (tree_inlined_location): Declare.
	(valid_new_delete_pair_p): Declare.

gcc/c-family/ChangeLog:

	PR middle-end/98166
	PR c++/57111
	PR middle-end/98160
	* c-attribs.c (maybe_add_noinline): New function.
	(handle_malloc_attribute): Call it.  Use ATTR_FLAG_INTERNAL.
	Implicitly add attribute noinline to functions not declared inline
	and warn on those.

libstdc++-v3/ChangeLog:
	* testsuite/ext/vstring/requirements/exception/basic.cc: Suppress
	a false positive warning.
	* testsuite/ext/vstring/requirements/exception/propagation_consistent.cc:
	  Same.

gcc/testsuite/ChangeLog:

	PR middle-end/98166
	PR c++/57111
	PR middle-end/98160
	* g++.dg/warn/Wmismatched-dealloc-2.C: Adjust test of expected warning.
	* g++.dg/warn/Wmismatched-new-delete.C: Same.
	* gcc.dg/Wmismatched-dealloc.c: Same.
	* c-c++-common/Wfree-nonheap-object-2.c: New test.
	* c-c++-common/Wfree-nonheap-object-3.c: New test.
	* c-c++-common/Wfree-nonheap-object.c: New test.
	* c-c++-common/Wmismatched-dealloc.c: New test.
	* g++.dg/warn/Wfree-nonheap-object-3.C: New test.
	* g++.dg/warn/Wfree-nonheap-object-4.C: New test.
	* g++.dg/warn/Wmismatched-dealloc-2.C: New test.
	* g++.dg/warn/Wmismatched-new-delete-2.C: New test.
	* g++.dg/warn/Wmismatched-new-delete.C: New test.
	* gcc.dg/Wmismatched-dealloc-2.c: New test.
	* gcc.dg/Wmismatched-dealloc-3.c: New test.
	* gcc.dg/Wmismatched-dealloc.c: New test.
2020-12-14 13:30:00 -07:00
François Dumont
8e56e4d956 libstdc++: Fix several _GLIBCXX_DEBUG tests
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/array/debug/back2_neg.cc: target c++14 because assertion
	for constexpr is disabled in C++11.
	* testsuite/23_containers/array/debug/front2_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc: Likewise.
	* testsuite/23_containers/vector/debug/multithreaded_swap.cc: Include <memory>
	for shared_ptr.
2020-12-14 07:46:25 +01:00
GCC Administrator
9855e8a90d Daily bump. 2020-12-13 00:16:19 +00:00
François Dumont
815eb852a2 libstdc++: Fix _GLIBCXX_DEBUG mode constexpr compatibility
The __glibcxx_check_can_[increment|decrement]_range macros are using the
_GLIBCXX_DEBUG_VERIFY_COND_AT macro which is not constexpr compliant and will produce nasty
diagnostics rather than the std::__failed_assertion dedicated to constexpr. Replace it with
correct _GLIBCXX_DEBUG_VERIFY_AT_F.

libstdc++-v3/ChangeLog:

	* include/debug/macros.h (__glibcxx_check_can_increment_range): Replace
	_GLIBCXX_DEBUG_VERIFY_COND_AT usage with _GLIBCXX_DEBUG_VERIFY_AT_F.
	(__glibcxx_check_can_decrement_range): Likewise.
	* testsuite/25_algorithms/copy_backward/constexpr.cc (test03): New.
	* testsuite/25_algorithms/copy/debug/constexpr_neg.cc: New test.
	* testsuite/25_algorithms/copy_backward/debug/constexpr_neg.cc: New test.
	* testsuite/25_algorithms/equal/constexpr_neg.cc: New test.
	* testsuite/25_algorithms/equal/debug/constexpr_neg.cc: New test.
2020-12-12 18:07:45 +01:00
GCC Administrator
35af87784e Daily bump. 2020-12-11 18:22:52 +00:00
Jonathan Wakely
2ea62857a3 libstdc++: Remove redundant branches in countl_one and countr_one [PR 98226]
There's no need to explicitly check for the maximum value, because the
function we call handles it correctly anyway.

libstdc++-v3/ChangeLog:

	PR libstdc++/98226
	* include/std/bit (__countl_one, __countr_one): Remove redundant
	branches.
2020-12-10 21:57:42 +00:00
GCC Administrator
ca2bd94949 Daily bump. 2020-12-10 00:16:47 +00:00
Jonathan Wakely
0aa1786d34 libstdc++: Fix build failure for target with no way to sleep
In previous releases the std::this_thread::sleep_for function was only
declared if the target supports multiple threads. I changed that
recently in r11-2649-g5bbb1f3000c57fd4d95969b30fa0e35be6d54ffb so that
sleep_for could be used single-threaded. But that means that targets
using --disable-threads are now required to provide some way to sleep.
This breaks the build for (at least) AVR when trying to build a hosted
library.

This patch adds a new autoconf macro that is defined when no way to
sleep is available, and uses that to suppress the sleeping functions in
std::this_thread.

The #error in src/c++11/thread.cc is retained for the case where there
is no sleep function available but multiple threads are supported. This
is consistent with previous releases, but that #error could probably be
removed without any consequences.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Define NO_SLEEP
	if none of nanosleep, sleep and Sleep is available.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/std/thread [_GLIBCXX_NO_SLEEP] (__sleep_for): Do
	not declare.
	[_GLIBCXX_NO_SLEEP] (sleep_for, sleep_until): Do not
	define.
	* src/c++11/thread.cc [_GLIBCXX_NO_SLEEP] (__sleep_for): Do
	not define.
2020-12-09 16:56:54 +00:00
GCC Administrator
f6e8e2797e Daily bump. 2020-12-09 00:16:50 +00:00
Jason Merrill
4ed1dc1275 c++: Fix defaulted <=> fallback to < and == [PR96299]
I thought I had implemented P1186R3, but apparently I didn't read it closely
enough to understand the point of the paper, namely that for a defaulted
operator<=>, if a member type doesn't have a viable operator<=>, we will use
its operator< and operator== if the defaulted operator has an specific
comparison category as its return type; the compiler can't guess if it
should be strong_ordering or something else, but the user can make that
choice explicit.

The libstdc++ test change was necessary because of the change in
genericize_spaceship from op0 > op1 to op1 < op0; this should be equivalent,
but isn't because of PR88173.

gcc/cp/ChangeLog:

	PR c++/96299
	* cp-tree.h (build_new_op): Add overload that omits some parms.
	(genericize_spaceship): Add location_t parm.
	* constexpr.c (cxx_eval_binary_expression): Pass it.
	* cp-gimplify.c (genericize_spaceship): Pass it.
	* method.c (genericize_spaceship): Handle class-type arguments.
	(build_comparison_op): Fall back to op</== when appropriate.

gcc/testsuite/ChangeLog:

	PR c++/96299
	* g++.dg/cpp2a/spaceship-synth-neg2.C: Move error.
	* g++.dg/cpp2a/spaceship-p1186.C: New test.

libstdc++-v3/ChangeLog:

	PR c++/96299
	* testsuite/18_support/comparisons/algorithms/partial_order.cc:
	One more line needs to use VERIFY instead of static_assert.
2020-12-08 15:12:25 -05:00
Jonathan Wakely
edbbf7363c libstdc++: Adjust whitespace in documentation
libstdc++-v3/ChangeLog:

	* doc/xml/manual/appendix_contributing.xml: Use consistent
	indentation.
	* doc/html/manual/source_code_style.html: Regenerate.
2020-12-08 13:36:45 +00:00
GCC Administrator
6e1edf48eb Daily bump. 2020-12-06 00:16:44 +00:00
Iain Sandoe
1352bc88a0 Darwin : Update libtool and dependencies for Darwin20 [PR97865]
The change in major version (and the increment from Darwin19 to 20)
caused libtool tests to fail which resulted in incorrect build settings
for shared libraries.

We take this opportunity to sort out the shared undefined symbols state
rather than propagating the current unsound behaviour into a new rev.

This change means that we default to the case that missing symbols are
considered an error, and if one wants to allow this intentionally, the
confiuration for that case should be set appropriately.

Three existing cases need undefined dynamic lookup:
 libitm, where there is already a configuration mechanism to add the
         flags.
 libcc1, where we add simple configuration to add the flags for Darwin.
 libsanitizer, where we can add to the existing extra flags.

libcc1/ChangeLog:

	PR target/97865
	* Makefile.am: Add dynamic_lookup to LD flags for Darwin.
	* configure.ac: Test for Darwin host and set a flag.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

libitm/ChangeLog:

	PR target/97865
	* configure.tgt: Add dynamic_lookup to XLDFLAGS for Darwin.
	* configure: Regenerate.

libsanitizer/ChangeLog:

	PR target/97865
	* configure.tgt: Add dynamic_lookup to EXTRA_CXXFLAGS for
	Darwin.
	* configure: Regenerate.

ChangeLog:

	PR target/97865
	* libtool.m4: Update handling of Darwin platform link flags
	for Darwin20.

gcc/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libatomic/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libbacktrace/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libffi/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libgfortran/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libgomp/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libhsail-rt/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libobjc/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libphobos/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libquadmath/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libssp/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libvtv/ChangeLog:

	PR target/97865
	* configure: Regenerate.

zlib/ChangeLog:

	PR target/97865
	* configure: Regenerate.
2020-12-05 08:43:20 +00:00
GCC Administrator
c5fd8a9157 Daily bump. 2020-12-05 00:16:39 +00:00
Jakub Jelinek
9715663f7d c++: Change __builtin_source_location to use __PRETTY_FUNCTION__ instead of __FUNCTION__ [PR80780]
On Tue, Dec 01, 2020 at 01:03:52PM +0000, Jonathan Wakely via Gcc-patches wrote:
> I mentioned in PR 80780 that a __builtin__PRETTY_FUNCTION would have
> been nice, because __FUNCTION__ isn't very useful for C++, because of
> overloading and namespace/class scopes. There are an unlimited number
> of functions that have __FUNCTION__ == "s", e.g. "ns::s(int)" and
> "ns::s()" and "another_scope::s::s<T...>(T...)" etc.
>
> Since __builtin_source_location() can do whatever it wants (without
> needing to add __builtin__PRETTY_FUNCTION) it might be nice to use the
> __PRETTY_FUNCTION__ string. JeanHeyd's tests would still need changes,
> because the name would be "s::s(void*)" not "s::s" but that still
> seems better for users.

When I've added template tests for the previous patch, I have noticed that
the current __builtin_source_location behavior is not really __FUNCTION__,
just close, because e.g. in function template __FUNCTION__ is still
"bar" but __builtin_source_location gave "bar<0>".

Anyway, this patch implements above request to follow __PRETTY_FUNCTION__
(on top of the earlier posted patch).

2020-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR c++/80780
	* cp-gimplify.c (fold_builtin_source_location): Use 2 instead of 0
	as last argument to cxx_printable_name.

	* g++.dg/cpp2a/srcloc1.C (quux): Use __PRETTY_FUNCTION__ instead of
	function.
	* g++.dg/cpp2a/srcloc2.C (quux): Likewise.
	* g++.dg/cpp2a/srcloc15.C (S::S): Likewise.
	(bar): Likewise.  Adjust expected column.
	* g++.dg/cpp2a/srcloc17.C (S::S): Likewise.
	(bar): Likewise.  Adjust expected column.

	* testsuite/18_support/source_location/1.cc (main): Adjust for
	__builtin_source_location using __PRETTY_FUNCTION__-like names instead
	__FUNCTION__-like.
	* testsuite/18_support/source_location/consteval.cc (main): Likewise.
2020-12-04 08:08:39 +01:00
GCC Administrator
b8dd0ef74d Daily bump. 2020-12-04 00:16:36 +00:00
Martin Sebor
dce6c58db8 Add support for detecting mismatched allocation/deallocation calls.
PR c++/90629 - Support for -Wmismatched-new-delete
PR middle-end/94527 - Add an __attribute__ that marks a function as freeing an object

gcc/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* builtins.c (access_ref::access_ref): Initialize new member.
	(compute_objsize): Use access_ref::deref.  Handle simple pointer
	assignment.
	(expand_builtin): Remove handling of the free built-in.
	(call_dealloc_argno): Same.
	(find_assignment_location): New function.
	(fndecl_alloc_p): Same.
	(gimple_call_alloc_p): Same.
	(call_dealloc_p): Same.
	(matching_alloc_calls_p): Same.
	(warn_dealloc_offset): Same.
	(maybe_emit_free_warning): Same.
	* builtins.h (struct access_ref): Declare new member.
	(maybe_emit_free_warning): Make extern.  Make use of access_ref.
	Handle -Wmismatched-new-delete.
	* calls.c (initialize_argument_information): Call
	maybe_emit_free_warning.
	* doc/extend.texi (attribute malloc): Update.
	* doc/invoke.texi (-Wfree-nonheap-object): Expand documentation.
	(-Wmismatched-new-delete): Document new option.
	(-Wmismatched-dealloc): Document new option.

gcc/c-family/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* c-attribs.c (handle_dealloc_attribute): New function.
	(handle_malloc_attribute): Handle argument forms of attribute.
	* c.opt (-Wmismatched-dealloc): New option.
	(-Wmismatched-new-delete): New option.

gcc/testsuite/ChangeLog:

	PR c++/90629
	PR middle-end/94527
	* g++.dg/asan/asan_test.cc: Fix a bug.
	* g++.dg/warn/delete-array-1.C: Add expected warning.
	* g++.old-deja/g++.other/delete2.C: Add expected warning.
	* g++.dg/warn/Wfree-nonheap-object-2.C: New test.
	* g++.dg/warn/Wfree-nonheap-object.C: New test.
	* g++.dg/warn/Wmismatched-new-delete.C: New test.
	* g++.dg/warn/Wmismatched-dealloc-2.C: New test.
	* g++.dg/warn/Wmismatched-dealloc.C: New test.
	* gcc.dg/Wmismatched-dealloc.c: New test.
	* gcc.dg/analyzer/malloc-1.c: Prune out expected warning.
	* gcc.dg/attr-malloc.c: New test.
	* gcc.dg/free-1.c: Adjust text of expected warning.
	* gcc.dg/free-2.c: Same.
	* gcc.dg/torture/pr71816.c: Prune out expected warning.
	* gcc.dg/tree-ssa/pr19831-2.c: Add an expected warning.
	* gcc.dg/Wfree-nonheap-object-2.c: New test.
	* gcc.dg/Wfree-nonheap-object-3.c: New test.
	* gcc.dg/Wfree-nonheap-object.c: New test.

libstdc++-v3/ChangeLog:

	* testsuite/ext/vstring/modifiers/clear/56166.cc: Suppress a false
	positive warning.
2020-12-03 15:43:32 -07:00
Jonathan Wakely
656131e06a libstdc++: Fix typos in #error strings
libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: Remove stray
	word from copy&paste.
	* testsuite/26_numerics/bit/bit.cast/version.cc: Likewise.
2020-12-03 19:31:19 +00:00
Jonathan Wakely
44ac1ea0e2 libstdc++: Update C++20 library implementation status
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2020.xml: Update C++20 status.
	* doc/html/*: Regenerate.
2020-12-03 19:17:13 +00:00
JeanHeyd Meneide
57d76ee9cf libtdc++: Define std::source_location for C++20
This doesn't define a new _GLIBCXX_HAVE_BUILTIN_SOURCE_LOCATION macro.
because using __has_builtin(__builtin_source_location) is sufficient.
Currently only GCC supports it, but if/when Clang and Intel add it the
__has_builtin check should for them too.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Add <source_location>.
	* include/Makefile.am: Add <source_location>.
	* include/Makefile.in: Regenerate.
	* include/std/version (__cpp_lib_source_location): Define.
	* include/std/source_location: New file.
	* testsuite/18_support/source_location/1.cc: New test.
	* testsuite/18_support/source_location/consteval.cc: New test.
	* testsuite/18_support/source_location/srcloc.h: New test.
	* testsuite/18_support/source_location/version.cc: New test.
2020-12-03 19:17:13 +00:00
Jonathan Wakely
9e433b3461 libstdc++: Add std::bit_cast for C++20 [PR 93121]
Thanks to Jakub's addition of the built-in, we can add this to the
library now. The compiler tests for the built-in are quite extensive,
including verifying the constraints, so this only adds minimal tests to
the library testsuite.

This doesn't add a new _GLIBCXX_HAVE_BUILTIN_BIT_CAST because using
__has_builtin(__builtin_bit_cast) works for GCC and versions of Clang
that provide the built-in.

libstdc++-v3/ChangeLog:

	PR libstdc++/93121
	* include/std/bit (__cpp_lib_bit_cast, bit_cast): Define.
	* include/std/version (__cpp_lib_bit_cast): Define.
	* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: New test.
	* testsuite/26_numerics/bit/bit.cast/version.cc: New test.
2020-12-03 19:17:13 +00:00
Jonathan Wakely
3843fa2d75 libstdc++: Update powerpc-linux baselines for GCC 10.1
This should have been done before the GCC 10.1 release.

libstdc++-v3/ChangeLog:

	* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt:
	Update.
	* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt:
	Update.
2020-12-03 17:18:28 +00:00
Jonathan Wakely
91cfacc4b5 libstdc++: Disable std::array assertions for C++11 constexpr
The recent changes to add assertions to std::array broke the functions
that need to be constexpr in C++11, because of the restrictive rules for
constexpr functions in C++11.

This simply disables the assertions for C++11 mode, so the functions can
be constexpr again.

libstdc++-v3/ChangeLog:

	* include/std/array (array::operator[](size_t) const, array::front() const)
	(array::back() const) [__cplusplus == 201103]: Disable
	assertions.
	* testsuite/23_containers/array/element_access/constexpr_element_access.cc:
	Check for correct values.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/23_containers/array/debug/constexpr_c++11.cc: New test.
2020-12-03 17:08:01 +00:00
GCC Administrator
11860cf440 Daily bump. 2020-12-03 00:16:47 +00:00
Jonathan Wakely
dc2b372ed1 libstdc++: Fix std::any pretty printer [PR 68735]
This fixes errors seen on powerpc64 (big endian only) due to the
printers for std::any and std::experimental::any being unable to find
the manager function.

libstdc++-v3/ChangeLog:

	PR libstdc++/65480
	PR libstdc++/68735
	* python/libstdcxx/v6/printers.py (function_pointer_to_name):
	New helper function to get the name of a function from its
	address.
	(StdExpAnyPrinter.__init__): Use it.
2020-12-02 21:39:08 +00:00
Jonathan Wakely
dd053eea0b libstdc++: Use libatomic for tests on all 32-bit powerpc targets
In addition to the existing powerpc targets, powerpc64 needs libatomic
for 64-bit atomics when testing the 32-bit multilib with -m32. Adjust
the existing target checks to match all 32-bit powerpc targets, but not
64-bit ones.

libstdc++-v3/ChangeLog:

	* testsuite/lib/dg-options.exp (add_options_for_libatomic):
	Replace powerpc-ibm-aix* and powerpc*-*-darwin* with check for
	powerpc && ilp32.
2020-12-02 16:37:56 +00:00
Jonathan Wakely
8b2c3b5af3 libstdc++: Use longer timeout for istream::gcount() overflow tests
On targets with 32-bit poitners these tests do extra work, so give them
longer to run.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_istream/ignore/char/94749.cc: Add
	dg-timeout-factor for ilp32 targets.
	* testsuite/27_io/basic_istream/ignore/wchar_t/94749.cc:
	Likewise.
2020-12-02 12:34:20 +00:00
Jonathan Wakely
74270a546c libstdc++: Fix null pointer dereferences in __gnu_cxx::rope
This fixes UBsan errors like:

/usr/include/c++/10/ext/ropeimpl.h:593:9: runtime error: member access within null pointer of type 'struct _RopeRep'
/usr/include/c++/10/ext/ropeimpl.h:593:9: runtime error: member call on null pointer of type 'struct _Rope_rep_base'
/usr/include/c++/10/ext/rope:556:17: runtime error: reference binding to null pointer of type 'struct allocator_type'
/usr/include/c++/10/ext/ropeimpl.h:593:9: runtime error: reference binding to null pointer of type 'struct allocator_type'
/usr/include/c++/10/ext/rope:1700:30: runtime error: member call on null pointer of type 'struct new_allocator'
/usr/include/c++/10/ext/new_allocator.h:105:29: runtime error: member call on null pointer of type 'struct new_allocator'
/usr/include/c++/10/ext/rope:1702:26: runtime error: reference binding to null pointer of type 'const struct allocator'
/usr/include/c++/10/bits/allocator.h:148:34: runtime error: reference binding to null pointer of type 'const struct new_allocator'
/usr/include/c++/10/ext/rope:1664:39: runtime error: reference binding to null pointer of type 'const struct allocator'
/usr/include/c++/10/ext/rope:1665:9: runtime error: reference binding to null pointer of type 'const struct allocator_type'
/usr/include/c++/10/ext/rope:725:36: runtime error: reference binding to null pointer of type 'const struct allocator_type'
/usr/include/c++/10/ext/rope:614:64: runtime error: reference binding to null pointer of type 'const struct allocator_type'

The problem is calling r->_M_get_allocator() when r is null.

libstdc++-v3/ChangeLog:

	* include/ext/rope (rope::_S_concat_char_iter)
	(rope::_S_destr_concat_char_iter): Add allocator parameter.
	(rope::push_back, rope::append, rope::insert, operator+):
	Pass allocator.
	* include/ext/ropeimpl.h (rope::_S_concat_char_iter)
	(rope::_S_destr_concat_char_iter): Add allocator parameter
	and use it.
	(_Rope_char_ref_proxy::operator=(_CharT)): Pass allocator.
2020-12-02 12:29:00 +00:00
Jonathan Wakely
d38fbb5a86 libstdc++: Fix indentation in rope
libstdc++-v3/ChangeLog:

	* include/ext/rope: Fix indentation of access specifiers.
2020-12-02 12:28:22 +00:00
Jonathan Wakely
670f5095e4 libstdc++: Make preprocessor checks for __cpp_lib_atomic_wait consistent
This changes some #ifdef checks to use #if instead.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_timed_wait.h: Use #if instead of #ifdef.
	* include/bits/semaphore_base.h: Likewise.
	* include/std/version: Remove trailing whitespace.
2020-12-02 00:39:22 +00:00
Jonathan Wakely
a70384f94c libstdc++: Fix filesystem::path pretty printer test failure
On some systems libstdc++-prettyprinters/cxx17.cc FAILs with this error:

skipping: Python Exception <type 'exceptions.AttributeError'> 'gdb.Type' object has no attribute 'name': ^M
got: $27 = filesystem::path "/dir/."^M
FAIL: libstdc++-prettyprinters/cxx17.cc print path2

The gdb.Type.name attribute isn't present in GDB 7.6, so we get an
exception from StdPathPrinter._iterator.__next__ trying to use it.
The StdPathPrinter._iterator is already passed the type's name in its
constructor, so we can just store that and use it instead of
gdb.Type.name.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdExpPathPrinter): Store the
	name of the type and pass it to the iterator.
	(StdPathPrinter): Likewise.
	* testsuite/libstdc++-prettyprinters/filesystem-ts.cc: New test.
2020-12-02 00:39:21 +00:00
GCC Administrator
e0f5e79267 Daily bump. 2020-12-02 00:16:41 +00:00
Thomas Rodgers
6591e42269 Add feature test macro for atomic<T>::wait
Adds __cpp_lib_atomic_wait feature test macro which was overlooked in
the initial commit of this feature. Replaces uses of
_GLIBCXX_HAVE_ATOMIC_WAIT.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h: Replace usage of
	_GLIBCXX_HAVE_ATOMIC_WAIT with __cpp_lib_atomic_wait.
	* include/bits/atomic_timed_wait.h: Likewise.
	* include/bits/atomic_wait.h: Define __cpp_lib_atomic_wait
	feature test macro.
	* include/bits/semaphore_base.h: Replace usage of
	_GLIBCXX_HAVE_ATOMIC_WAIT with __cpp_lib_atomic_wait.
	* include/std/atomic: Likewise.
	* include/std/latch: Likewise.
	* include/std/semaphore: Likewise.
	* include/std/version: Define __cpp_lib_atomic wait
	feature test macro and replace usage of
	_GLIBCXX_HAVE_ATOMIC_WAIT.
	* testsuite/29_atomics/atomic/wait_notify/1.cc: New test.
	* testsuite/29_atomics/atomic/wait_notify/2.cc: Likewise.
2020-12-01 15:43:17 -08:00
Michael Weghorn
39836f8324 libstdc++: Pretty printers for _Bit_reference and _Bit_iterator
'std::_Bit_iterator' and 'std::_Bit_const_iterator' are the iterators
used by 'std::vector<bool>'.
'std::_Bit_reference' is e.g. used in range-based for loops over
'std::vector<bool>'  like

    std::vector<bool> vb {true, false, false};
    for (auto b : vb) {
        // b is of type std::_Bit_reference here
        // ...
    }

Like iterators of vectors for other types, the actual value is printed.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdBitIteratorPrinter)
	(StdBitReferencePrinter): Add pretty-printers for
	_Bit_reference, _Bit_iterator and _Bit_const_iterator.
	* testsuite/libstdc++-prettyprinters/simple.cc: Test
	std::_Bit_reference, std::_Bit_iterator and
	std::_Bit_const_iterator.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
2020-12-01 21:35:32 +00:00
Jonathan Wakely
6aa1227400 libstdc++: Simplify detection of built-in functions
This fixes a regression affecting the Intel compiler. Because that
compiler defines __GNUC__ to match whatever version of GCC it finds on
the host system, it might claim to be a brand new GCC despite not
actually supporting all the built-ins that the latest GCC supports. This
means the config checks for __GNUC__ don't work. Most recently this
broke when r11-3569-g73ae6eb572515ad627b575a7fbdfdd47a4368e1c switched
us from using __is_same_as to __is_same when __GNUC__ >= 11.

Because __has_builtin is supported by all of GCC, Clang, and Intel we can
use that to reliably detect whether a given built-in is supported,
instead of hardcoding anything based on __GNUC__. The big caveat is
that for versions of Clang <= 9.0.0 and for (as far as I can tell) all
released versions of Intel icc, __has_builtin only evaluates to true for
built-ins with a name starting "__builtin_". For __is_aggregate,
__is_same, and __has_unique_object_representations it's necessary to use
__is_identifier to check if it's a valid identifeir token instead.

The solution used in this patch is to define _GLIBCXX_HAS_BUILTIN and
use that instead of using __has_builtin directly. For compilers that
define __is_identifier as well as __has_builtin we use both, so that if
__has_builtin evaluates to false we try again using !__is_identifier.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX_HAS_BUILTIN): Define macro to
	work around different implementations of __has_builtin.
	(_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP)
	(_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE)
	(_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED)
	(_GLIBCXX_HAVE_BUILTIN_IS_SAME, _GLIBCXX_HAVE_BUILTIN_LAUNDER):
	Define using _GLIBCXX_HAS_BUILTIN.
2020-12-01 14:14:18 +00:00
Jonathan Wakely
0fb378761f libstdc++: Use longer timeout for slow running tests
libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_istream/get/char/lwg3464.cc: Add
	dg-timeout-factor directive.
	* testsuite/27_io/basic_istream/get/wchar_t/lwg3464.cc:
	Likewise.
2020-12-01 10:51:25 +00:00
Jonathan Wakely
58f71a34c6 libstdc++: Link test with libatomic if needed [PR 98003]
libstdc++-v3/ChangeLog:

	PR libstdc++/98003
	* testsuite/27_io/basic_syncbuf/sync_ops/1.cc: Add options for
	libatomic.
2020-12-01 10:37:38 +00:00
GCC Administrator
94358e4770 Daily bump. 2020-12-01 00:16:38 +00:00
Jonathan Wakely
82ac923da6 libstdc++: Add new C++20 headers to Doxygen settings
This doesn't actually have any effect unless you also change the
predefined value of __cplusplus, as it's currently 201703L. But if
somebody does want to do that, the new headers will get processed now.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Add <latch> and <semaphore>.
2020-11-30 15:02:03 +00:00
Jonathan Wakely
637800c7bb libstdc++: Reduce default test timeout to 360 seconds
The current default of 10 minutes is much longer than most tests need on
common hardware. The slow tests all now have a dg-timeout-factor
directive that gives them more time to run relative to the default. The
default can also be overridden in ~/.dejagnurc or DEJAGNU=site.exp, so
it seems unnecessary to have such a large default.

This reduces the default from 10 minutes to 6 minutes, which still seems
more than enough.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (libstdc++_init): Reduce
	default tool_timeout to 360.
2020-11-30 14:39:54 +00:00
Jonathan Wakely
b6a8e3479e libstdc++: Set dg-timeout-factor for more slow tests
As in r11-5449, this adds a muliplier to the timeout for slow tests.
This covers the majority of the <regex> and PSTL tests.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/specialized_algorithms/pstl/*: Add
	dg-timeout-factor.
	* testsuite/25_algorithms/pstl/*: Likewise.
	* testsuite/26_numerics/pstl/*: Likewise.
	* testsuite/28_regex/*: Likewise.
2020-11-30 14:39:54 +00:00
GCC Administrator
a9625c50dd Daily bump. 2020-11-30 00:16:27 +00:00
John David Anglin
4e4ba6478a Fix hppa64-hpux11 build to remove source paths from embedded path.
This change adds the +nodefaultrpath ld option to remove all library
paths that were specified with the -L option from the embedded path.

2020-11-29  John David Anglin  <danglin@gcc.gnu.org>

ChangeLog:
	* libtool.m4 (archive_cmds): Add +nodefaultrpath ld option on
	hppa64-*-hpux11*.

libatomic/ChangeLog:
	* configure: Regenerate.

libbacktrace/ChangeLog:
	* configure: Regenerate.

libcc1/ChangeLog:
	* configure: Regenerate.

libffi/ChangeLog:
	* configure: Regenerate.

libgfortran/ChangeLog:
	* configure: Regenerate.

libgomp/ChangeLog:
	* configure: Regenerate.

libhsail-rt/ChangeLog:
	* configure: Regenerate.

libitm/ChangeLog:
	* configure: Regenerate.

libobjc/ChangeLog:
	* configure: Regenerate.

liboffloadmic/ChangeLog:
	* configure: Regenerate.
	* plugin/configure: Regenerate.

libquadmath/ChangeLog:
	* configure: Regenerate.

libsanitizer/ChangeLog:
	* configure: Regenerate.

libssp/ChangeLog:
	* configure: Regenerate.

libstdc++-v3/ChangeLog:
	* configure: Regenerate.

libvtv/ChangeLog:
	* configure: Regenerate.

lto-plugin/ChangeLog:
	* configure: Regenerate.

zlib/ChangeLog:
	* configure: Regenerate.
2020-11-29 20:11:38 +00:00
GCC Administrator
e87559d202 Daily bump. 2020-11-28 00:16:38 +00:00
Jonathan Wakely
e8f83fa4fc libstdc++: Refactor dejagnu effective-target checks
This introduces two new procs to replace boilerplate in the
effective-target checks.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (v3_try_preprocess): Define
	new proc to preprocess a chunk of code.
	(v3_check_preprocessor_condition): Define new proc to test
	a preprocessor condition depending on GCC or libstdc++ macros.
	(check_v3_target_debug_mode, check_v3_target_normal_mode):
	Use v3_try_preprocess.
	(check_v3_target_normal_namespace)
	(check_v3_target_parallel_mode, check_v3_target_cstdint)
	(check_v3_target_cmath, check_v3_target_atomic_builtins)
	(check_v3_target_gthreads, check_v3_target_gthreads_timed)
	(check_v3_target_sleep, check_v3_target_sched_yield)
	(check_v3_target_string_conversions, check_v3_target_swprintf)
	(check_v3_target_binary_io, check_v3_target_nprocs): Use
	v3_check_preprocessor_condition.
	(check_effective_target_cxx11): Likewise.
	(check_effective_target_random_device): Likewise.
	(check_effective_target_tbb-backend): Likewise.
	(check_effective_target_futex): Likewise.
	(check_v3_target_little_endian) Call check_effective_target_le.
	(check_effective_target_atomic-builtins): New proc to define
	new effective-target keyword.
	(check_effective_target_gthreads-timed): Likewise.
2020-11-27 15:50:49 +00:00
Jonathan Wakely
4a7c799908 libstdc++: Fix -Wrange-loop-construct warnings in filesystem tests
Many tests do `for (const path& p : test_paths)` where test_paths is an
array of strings. To avoid -Wrange-loop-construct warnings the loop
variable should be an object, not a reference bound to a temporary.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/operations/absolute.cc: Avoid
	-Wrange-loop-construct warning.
	* testsuite/27_io/filesystem/path/append/source.cc: Likewise.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/path.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/copy.cc: Likewise.
	* testsuite/27_io/filesystem/path/decompose/extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/parent_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/relative_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_directory.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/itr/traversal.cc: Likewise.
	* testsuite/27_io/filesystem/path/modifiers/remove_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/replace_extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/replace_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/nonmember/append.cc: Likewise.
	* testsuite/27_io/filesystem/path/nonmember/cmp.cc: Likewise.
	* testsuite/27_io/filesystem/path/nonmember/cmp_c++20.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/nonmember/hash_value.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_parent_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_relative_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_directory.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_name.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_stem.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/is_relative.cc: Likewise.
	* testsuite/experimental/filesystem/operations/absolute.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/assign/copy.cc: Likewise.
	* testsuite/experimental/filesystem/path/compare/path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/construct/copy.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/extension.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/filename.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/parent_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/relative_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/root_directory.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/decompose/root_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/itr/traversal.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/modifiers/remove_filename.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/modifiers/replace_extension.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/modifiers/replace_filename.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/nonmember/hash_value.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_extension.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_filename.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_parent_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_relative_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_root_directory.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_root_name.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_root_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/has_stem.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/query/is_relative.cc:
	Likewise.
2020-11-27 13:34:22 +00:00
Jonathan Wakely
0d7d69ca4a libstdc++: Partially revert r11-5314
The changes in r11-5314 are broken, because it means we don't use
__gthread_once for the first few initializations, but after the program
becomes multi-threaded we will repeat the initialization, using
__gthread_once once this time. This leads to memory errors.

The use of __is_single_threaded() in locale:🆔:_M_id() is OK, because
the side effects are the same either way.

libstdc++-v3/ChangeLog:

	* src/c++98/locale.cc (locale::facet::_S_get_c_locale()):
	Revert change to use __is_single_threaded.
	* src/c++98/locale_init.cc (locale::_S_initialize()):
	Likewise.
2020-11-27 12:25:02 +00:00
GCC Administrator
d48df6f24b Daily bump. 2020-11-27 00:16:31 +00:00
Jonathan Wakely
61c71a6245 libstdc++: Define (and use) _GLIBCXX_HAVE_ATOMIC_WAIT
In order to simplify the preprocessor checks for whether __atomic_wait
is available, this commit does:

-#if defined _GLIBCXX_HAS_GTHREADS || _GLIBCXX_HAVE_LINUX_FUTEX
+#ifdef _GLIBCXX_HAVE_ATOMIC_WAIT

The original was wrong anyway, as it should have used 'defined' to check
_GLIBCXX_HAVE_LINUX_FUTEX (for consistency with how that's used
elsewhere).

The new macro is defined in <bits/atomic_wait.h> when the file is
defines __atomic_wait and related facilities. All other code that
depends on those features can just check the one macro.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_wait.h (_GLIBCXX_HAVE_ATOMIC_WAIT):
	Define.
	* include/bits/atomic_base.h: Check _GLIBCXX_HAVE_ATOMIC_WAIT.
	* include/bits/atomic_timed_wait.h: Likewise.
	* include/bits/semaphore_base.h: Likewise.
	* include/std/atomic: Likewise.
	* include/std/latch: Likewise.
	* include/std/semaphore: Likewise.
2020-11-26 23:53:09 +00:00
Jonathan Wakely
7198827486 libstdc++: Only define std::latch if atomic waiting is available
libstdc++-v3/ChangeLog:

	* include/std/latch: Depend on _GLIBCXX_HAS_GTHREADS and
	_GLIBCXX_HAVE_LINUX_FUTEX.
	* include/std/version (__cpp_lib_latch): Define conditionally.
2020-11-26 22:36:44 +00:00
Jonathan Wakely
1a00786414 libstc++: Fix typo in new check_effective_target_gthreads proc
Also fix copy&pasted comments referring to the wrong things.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (check_effective_target_gthreads):
	Call check_v3_target_gthreads not check_v3_target_gthreads_timed.
2020-11-26 21:43:18 +00:00
Jonathan Wakely
218cedd5a3 libstdc++: Set dg-timeout-factor for some slow tests
These tests are very, very slow to compile. If the testsuite is run with
a low tool_timeout value they are likely to fail. By adding a
multiplication factor to those tests, it's still possible to use a low
timeout without spurious failures.

libstdc++-v3/ChangeLog:

	* testsuite/28_regex/algorithms/regex_match/basic/string_range_01_03.cc:
	Add dg-timeout-factor directive.
	* testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/char/backref.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/63199.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/anymatcher.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/cjk_match.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_search/61720.cc: Likewise.
	* testsuite/28_regex/algorithms/regex_search/ecma/assertion.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc:
	Likewise.
	* testsuite/28_regex/basic_regex/ctors/deduction.cc: Likewise.
2020-11-26 16:15:53 +00:00
Jonathan Wakely
39e837cd75 libstdc++: Allow dejagnu tool_timeout to be overridden
This allows the default timeout for libstdc++ tests to be set by the
user, either in ~/.dejagnurc or a site.exp file that $DEJAGNU names.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (libstdc++_init): Only set
	tool_timeout if it hasn't been set by the user already.
2020-11-26 16:15:53 +00:00
Jonathan Wakely
10522ed108 libstdc++: Fix some more deadlocks in tests [PR 97936]
The missed notifications fixed in r11-5383 also happen in some other
tests which have similar code.

libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	* testsuite/29_atomics/atomic/wait_notify/bool.cc: Fix missed
	notifications by making the new thread wait until the parent
	thread is waiting on the condition variable.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
2020-11-26 16:15:52 +00:00
Jonathan Wakely
10ee46adf4 libstdc++: Add "futex" and "gthreads" effective-target keywords
This adds a new "futex" effective-target keyword that can be used to
selectively enable/disable tests based on _GLIBCXX_HAVE_LINUX_FUTEX,
instead of checking for that macro in the code.

It also adds "gthreads" as another one, to make the result of the
dg-require-gthreads directive usable in target selectors.

With these new keywords two tests that are currently only run for linux
can also be run for targets using gthr-single.h (e.g. AIX single-thread
multilib, and targets without a gthreads implementation).

libstdc++-v3/ChangeLog:

	* testsuite/18_support/96817.cc: Use new effective-target
	keywords to select supported targets more effectively.
	* testsuite/30_threads/call_once/66146.cc: Likewise.
	* testsuite/lib/libstdc++.exp (check_effective_target_futex):
	Define new proc.
	(check_effective_target_gthreads): Define new proc to replace
	dg-require-gthreads.
2020-11-26 16:15:52 +00:00
Rainer Orth
55ebb0d6fb ada: c++: Get rid of libposix4, librt on Solaris
I recently noticed that neither libposix4 nor librt are needed on
Solaris 11 any longer:

* libposix4 was renamed to librt in Solaris 7 back in 1998.

* librt was folded into libc in the OpenSolaris timeframe, leaving librt
  only as a filter on libc.  Thus, it's no longer needed on either
  Solaris 11 or Illumos.

The following patch removes both uses.  At the same time, Ada's use of
libthread has gone: it was folded into libc in Solaris 10 already.
TIME_LIBRARY and friends in g++ are likewise removed: Solaris was the
only user.

Bootstrapped without regressions on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.


2020-11-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc/cp:
	* g++spec.c (TIMELIB, TIME_LIBRARY): Remove.
	(lang_specific_driver): Remove TIME_LIBRARY handling.

	gcc:
	* config/sol2.h (TIME_LIBRARY): Remove.

	libstdc++-v3:
	* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Remove libposix4
	references.
	<solaris*>: Don't use -lrt any longer.
	* configure: Regenerate.

	* doc/xml/manual/configure.xml (--enable-libstdcxx-time=OPTION):
	Remove libposix4 reference.

	gcc/ada:
	* Makefile.rtl <sparc*-sun-solaris*> (THREADSLIB): Remove.
	(MISCLIB): Remove -lposix4.
	<*86-*-solaris2*>: Likewise.
	* libgnarl/s-osinte__solaris.ads (System.OS_Interface): Remove
	-lposix4 -lthread.
2020-11-26 13:01:30 +01:00
Jonathan Wakely
2762cb1df6 libstdc++: Fix undefined FILE* operations in test
We only need to check that the constructor doesn't clear errno, so
there's no need to use an invalid FILE* for that.

libstdc++-v3/ChangeLog:

	PR libstdc++/98001
	* testsuite/ext/stdio_filebuf/char/79820.cc: Do not pass invalid
	FILE* to constructor.
2020-11-26 11:25:55 +00:00
Jonathan Wakely
127aa17e16 libstdc++: Add new headers to stdc++.h
libstdc++-v3/ChangeLog:

	* include/precompiled/stdc++.h: Add new headers.
	* include/std/stop_token: Include <semaphore> unconditionally.
2020-11-26 11:25:55 +00:00
GCC Administrator
360258daf5 Daily bump. 2020-11-26 00:16:41 +00:00
Jonathan Wakely
dfc537e554 libstdc++: Remove redundant clock conversions in atomic waits
For the case where a timeout is specified using the system_clock we
perform a conversion to the preferred clock (which is either
steady_clock or system_clock itself), wait using __cond_wait_until_impl,
and then check the time by that clock again to see if it was reached.
This is entirely redundant, as we can just call __cond_wait_until_impl
directly. It will wait using the specified clock, and there's no need to
check the time twice. For the no_timeout case this removes two
unnecessary calls to the clock's now() function, and for the timeout
case it removes three calls.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_timed_wait.h (__cond_wait_until): Do not
	perform redundant conversions to the same clock.
2020-11-25 18:24:13 +00:00
Jonathan Wakely
7d2a98a727 libstdc++: Encapsulate __gthread_cond_t as std::__condvar
This introduces a new internal utility, std::__condvar, which is a
simplified form of std::condition_variable. It has no dependency on
<chrono> or std::unique_lock, which allows it to be used in
<bits/atomic_wait.h>.

This avoids repeating the #ifdef __GTHREAD_COND_INIT preprocessor
conditions and associated logic for initializing a __gthread_cond_t
correctly. It also encapsulates most of the __gthread_cond_xxx functions
as member functions of __condvar.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_timed_wait.h (__cond_wait_until_impl):
	Do not define when _GLIBCXX_HAVE_LINUX_FUTEX is defined. Use
	__condvar and mutex instead of __gthread_cond_t and
	unique_lock<mutex>.
	(__cond_wait_until): Likewise. Fix test for return value of
	__cond_wait_until_impl.
	(__timed_waiters::_M_do_wait_until): Use __condvar instead
	of __gthread_cond_t.
	* include/bits/atomic_wait.h: Remove <bits/unique_lock.h>
	include. Only include <bits/std_mutex.h> if not using futexes.
	(__platform_wait_max_value): Remove unused variable.
	(__waiters::lock_t): Use lock_guard instead of unique_lock.
	(__waiters::_M_cv): Use __condvar instead of __gthread_cond_t.
	(__waiters::_M_do_wait(__platform_wait_t)): Likewise.
	(__waiters::_M_notify()): Likewise. Use notify_one() if not
	asked to notify all.
	* include/bits/std_mutex.h (__condvar): New type.
	* include/std/condition_variable (condition_variable::_M_cond)
	(condition_variable::wait_until): Use __condvar instead of
	__gthread_cond_t.
	* src/c++11/condition_variable.cc (condition_variable): Define
	default constructor and destructor as defaulted.
	(condition_variable::wait, condition_variable::notify_one)
	(condition_variable::notify_all): Forward to corresponding
	member function of __condvar.
2020-11-25 18:24:13 +00:00
Jonathan Wakely
f76cad692a libstdc++: Fix testsuite helper functions [PR 97936]
This fixes a race condition in the util/atomic/wait_notify_util.h header
used by several tests, which should make the tests work properly.

libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	* testsuite/29_atomics/atomic/wait_notify/bool.cc: Re-eneable
	test.
	* testsuite/29_atomics/atomic/wait_notify/generic.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise.
	* testsuite/util/atomic/wait_notify_util.h: Fix missed
	notifications by making the new thread wait until the parent
	thread is waiting on the condition variable.
2020-11-25 18:24:12 +00:00
Jonathan Wakely
9d908b7fc4 libstdc++: Fix missing subsumption in std::iterator_traits [PR 97935]
libstdc++-v3/ChangeLog:

	PR libstdc++/97935
	* include/bits/iterator_concepts.h (__detail::__iter_without_category):
	New helper concept.
	(__iterator_traits::__cat): Use __detail::__iter_without_category.
	* testsuite/24_iterators/associated_types/iterator.traits.cc: New test.
2020-11-25 17:22:47 +00:00
Jonathan Wakely
1a8d1f54de libstdc++: Fix test failure on AIX
This fixes a failure on AIX 7.2:

FAIL: 17_intro/names.cc (test for excess errors)
Excess errors:
/home/jwakely/src/gcc/libstdc++-v3/testsuite/17_intro/names.cc:99: error: expected identifier before '(' token
/usr/include/sys/var.h:187: error: expected unqualified-id before '{' token
/usr/include/sys/var.h:187: error: expected ')' before '{' token
/usr/include/sys/var.h:337: error: expected unqualified-id before ';' token
/usr/include/sys/var.h:337: error: expected ')' before ';' token

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Do not test 'v' on AIX.
2020-11-25 17:22:47 +00:00
Jonathan Wakely
a5ccfd0460 libstdc++: Fix silly typos [PR 97936]
libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	* include/bits/atomic_wait.h (__platform_wait): Check errno,
	not just the value of EAGAIN.
	(__waiters::__waiters()): Fix name of data member.
2020-11-25 12:16:07 +00:00
Jonathan Wakely
ad9cbcee54 libstdc++: Fix handling of futex wake [PR 97936]
The __platform_wait function is supposed to wait until *addr != old.
The futex syscall checks the initial value and returns EAGAIN if *addr
!= old is already true, which should cause __platform_wait to return.
Instead it loops and keeps doing a futex wait, which keeps returning
EAGAIN.

libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	* include/bits/atomic_wait.h (__platform_wait): Return if futex
	sets EAGAIN.
	* testsuite/30_threads/latch/3.cc: Re-enable test.
	* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
2020-11-25 10:31:55 +00:00
GCC Administrator
1e2c9a2761 Daily bump. 2020-11-25 09:34:01 +00:00
Jonathan Wakely
a3313a2214 libstdc++: Disable failing tests [PR 97936]
These tests are unstable and causing failures due to timeouts. Disable
them until the cause can be found, so that testing doesn't have to wait
for them to timeout.

libstdc++-v3/ChangeLog:

	PR libstdc++/97936
	PR libstdc++/97944
	* testsuite/29_atomics/atomic_integral/wait_notify.cc: Disable.
	Do not require pthreads, but add -pthread when appropriate.
	* testsuite/30_threads/jthread/95989.cc: Likewise.
	* testsuite/30_threads/latch/3.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
2020-11-24 23:41:28 +00:00
Jonathan Wakely
7e0078f864 libstdc++: Run all tests in file
libstdc++-v3/ChangeLog:

	* testsuite/30_threads/jthread/95989.cc: Run all three test
	functions, not just the first one twice.
2020-11-24 14:59:41 +00:00
Jonathan Wakely
4bbd5d0c5f libstdc++: Throw instead of segfaulting in std::thread constructor [PR 67791]
This turns a mysterious segfault into an exception with a more useful
message. If the exception isn't caught, the user sees this instead of
just a segfault:

terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std:🧵 Operation not permitted
Aborted (core dumped)

libstdc++-v3/ChangeLog:

	PR libstdc++/67791
	* src/c++11/thread.cc (thread::_M_start_thread(_State_ptr, void (*)())):
	Check that gthreads is available before calling __gthread_create.
2020-11-24 14:59:40 +00:00
Jonathan Wakely
e253d36214 libstdc++: Use __libc_single_threaded for locale initialization
Most initialization of locales and facets happens before main() during
startup, when the program is likely to only have one thread. By using
the new __gnu_cxx::__is_single_threaded() function instead of checking
__gthread_active_p() we can avoid using pthread_once or atomics for the
common case.

That said, I'm not sure why we don't just use a local static variable
instead, as __cxa_guard_acquire() already optimizes for the
single-threaded case:

  static const bool init = (_S_initialize_once(), true);

I'll revisit that for GCC 12.

libstdc++-v3/ChangeLog:

	* src/c++98/locale.cc (locale::facet::_S_get_c_locale())
	(locale:🆔:_M_id() const): Use __is_single_threaded.
	* src/c++98/locale_init.cc (locale::_S_initialize()):
	Likewise.
2020-11-24 14:59:40 +00:00
GCC Administrator
8e6198d0f8 Daily bump. 2020-11-24 00:16:44 +00:00
Jonathan Wakely
1ccee0fbfa libstdc++: Fix variable declared with wrong type
libstdc++-v3/ChangeLog:

	* include/bits/semaphore_base.h
	(__platform_semaphore::_M_try_acquire_until): Fix type of
	variable.
2020-11-23 18:16:44 +00:00
Stephan Bergmann
0986d3bc62 libstdc++: Fix linker errors due to missing 'inline' keywords
libstdc++-v3/ChangeLog:

	* include/bits/atomic_wait.h (__thread_relax, __thread_yield):
	Add 'inline'.
2020-11-23 18:15:06 +00:00
Jonathan Wakely
92b47a321e libstdc++: Add configure checks for semaphores
This moves the checks for POSIX semaphores to configure time. As well as
requiring <semaphore.h> and SEM_VALUE_MAX, we also require the
sem_timedwait function. That was only optional in POSIX 2001 (and is
absent on Darwin).

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CHECK_GTHREADS): Check for
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/bits/semaphore_base.h (_GLIBCXX_HAVE_POSIX_SEMAPHORE):
	Check autoconf macro instead of defining it here.
2020-11-23 18:12:39 +00:00
Jonathan Wakely
183ae52b22 libstdc++: make atomic waiting depend on gthreads or futexes
libstdc++-v3/ChangeLog:

	* include/bits/atomic_wait.h: Do not define anything unless
	gthreads or futexes are available.
	* include/bits/atomic_timed_wait.h: Likewise.
	* include/bits/semaphore_base.h: Likewise.
	* include/std/semaphore: Likewise.
	* include/bits/atomic_base.h (atomic_flag::wait)
	(atomic_flag::notify_one, atomic_flag::notify_all)
	(__atomic_base<I>::wait, __atomic_base<I>::notify_one)
	(__atomic_base<I>::notify_all, __atomic_base<P*>::wait)
	(__atomic_base<P*>::notify_one, __atomic_base<P*>::notify_all)
	(__atomic_impl::wait, __atomic_impl::notify_one)
	(__atomic_impl::notify_all, __atomic_float::wait)
	(__atomic_float::notify_one, __atomic_float::notify_all)
	(__atomic_ref::wait, __atomic_ref::notify_one)
	(__atomic_ref::notify_all): Only define if gthreads or futexes
	are available.
	* include/std/atomic (atomic::wait, atomic::notify_one)
	(atomic::notify_all): Likewise.
	* include/std/version (__cpp_lib_semaphore): Define
	conditionally.
2020-11-23 18:12:39 +00:00
Jonathan Wakely
fd62daea40 libstdc++: Link tests to libatomic as required [PR 97948]
libstdc++-v3/ChangeLog:

	PR libstdc++/97948
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Add options
	for libatomic.
	* testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
2020-11-23 16:06:50 +00:00
GCC Administrator
7a97e2fcf7 Daily bump. 2020-11-22 00:16:24 +00:00
Jonathan Wakely
62d19588b9 libstdc++: Fix atomic waiting for non-linux targets
This fixes some UNRESOLVED tests on (at least) Solaris and Darwin, and
disables some tests that hang forever on Solaris. A proper fix is still
needed.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h (atomic_flag::wait): Use correct
	type for __atomic_wait call.
	* include/bits/atomic_timed_wait.h (__atomic_wait_until): Check
	_GLIBCXX_HAVE_LINUX_FUTEX.
	* include/bits/atomic_wait.h (__atomic_notify): Likewise.
	* include/bits/semaphore_base.h (_GLIBCXX_HAVE_POSIX_SEMAPHORE):
	Only define if SEM_VALUE_MAX or _POSIX_SEM_VALUE_MAX is defined.
	* testsuite/29_atomics/atomic/wait_notify/bool.cc: Disable on
	non-linux targes.
	* testsuite/29_atomics/atomic/wait_notify/generic.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise.
2020-11-21 17:50:13 +00:00
GCC Administrator
82e5048e70 Daily bump. 2020-11-21 00:16:29 +00:00
Thomas Rodgers
83a1beee27 libstdc++: Add C++2a synchronization support
Add support for -
  * atomic_flag::wait/notify_one/notify_all
  * atomic::wait/notify_one/notify_all
  * counting_semaphore
  * binary_semaphore
  * latch

libstdc++-v3/ChangeLog:

	* include/Makefile.am (bits_headers): Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/atomic_base.h (__atomic_flag::wait): Define.
	(__atomic_flag::notify_one): Likewise.
	(__atomic_flag::notify_all): Likewise.
	(__atomic_base<_Itp>::wait): Likewise.
	(__atomic_base<_Itp>::notify_one): Likewise.
	(__atomic_base<_Itp>::notify_all): Likewise.
	(__atomic_base<_Ptp*>::wait): Likewise.
	(__atomic_base<_Ptp*>::notify_one): Likewise.
	(__atomic_base<_Ptp*>::notify_all): Likewise.
	(__atomic_impl::wait): Likewise.
	(__atomic_impl::notify_one): Likewise.
	(__atomic_impl::notify_all): Likewise.
	(__atomic_float<_Fp>::wait): Likewise.
	(__atomic_float<_Fp>::notify_one): Likewise.
	(__atomic_float<_Fp>::notify_all): Likewise.
	(__atomic_ref<_Tp>::wait): Likewise.
	(__atomic_ref<_Tp>::notify_one): Likewise.
	(__atomic_ref<_Tp>::notify_all): Likewise.
	(atomic_wait<_Tp>): Likewise.
	(atomic_wait_explicit<_Tp>): Likewise.
	(atomic_notify_one<_Tp>): Likewise.
	(atomic_notify_all<_Tp>): Likewise.
	* include/bits/atomic_wait.h: New file.
	* include/bits/atomic_timed_wait.h: New file.
	* include/bits/semaphore_base.h: New file.
	* include/std/atomic (atomic<bool>::wait): Define.
	(atomic<bool>::wait_one): Likewise.
	(atomic<bool>::wait_all): Likewise.
	(atomic<_Tp>::wait): Likewise.
	(atomic<_Tp>::wait_one): Likewise.
	(atomic<_Tp>::wait_all): Likewise.
	(atomic<_Tp*>::wait): Likewise.
	(atomic<_Tp*>::wait_one): Likewise.
	(atomic<_Tp*>::wait_all): Likewise.
	* include/std/latch: New file.
	* include/std/semaphore: New file.
	* include/std/version: Add __cpp_lib_semaphore and
	__cpp_lib_latch defines.
	* testsuite/29_atomics/atomic/wait_notify/bool.cc: New test.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/generic.cc: Liekwise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
	* testsuite/30_threads/semaphore/1.cc: New test.
	* testsuite/30_threads/semaphore/2.cc: Likewise.
	* testsuite/30_threads/semaphore/least_max_value_neg.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_for.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_posix.cc: Likewise.
	* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
	* testsuite/30_threads/latch/1.cc: New test.
	* testsuite/30_threads/latch/2.cc: New test.
	* testsuite/30_threads/latch/3.cc: New test.
	* testsuite/util/atomic/wait_notify_util.h: New File.
2020-11-20 14:40:18 -08:00
François Dumont
ba23e045fc libstdc++: Limit memory allocation in stable_sort/inplace_merge (PR 83938)
Reduce memory allocation in stable_sort/inplace_merge algorithms to what is needed
by the implementation.

Co-authored-by: John Chang  <john.chang@samba.tv>

libstdc++-v3/ChangeLog:

	PR libstdc++/83938
	* include/bits/stl_tempbuf.h (get_temporary_buffer): Change __len
	computation in the loop to avoid truncation.
	* include/bits/stl_algo.h:
	(__inplace_merge): Take temporary buffer length from smallest range.
	(__stable_sort): Limit temporary buffer length.
	* testsuite/25_algorithms/inplace_merge/1.cc (test4): New.
	* testsuite/performance/25_algorithms/stable_sort.cc: Test stable_sort
	under different heap memory conditions.
	* testsuite/performance/25_algorithms/inplace_merge.cc: New test.
2020-11-20 22:25:04 +01:00
François Dumont
90bf60c3c2 libstdc++: _Rb_tree code cleanup, remove lambdas
Use new template parameters to replace usage of lambdas to move or not
tree values on copy.

libstdc++-v3/ChangeLog:

	* include/bits/move.h (_GLIBCXX_FWDREF): New.
	* include/bits/stl_tree.h: Adapt to use latter.
	(_Rb_tree<>::_M_clone_node): Add _MoveValue template parameter.
	(_Rb_tree<>::_M_mbegin): New.
	(_Rb_tree<>::_M_begin): Use latter.
	(_Rb_tree<>::_M_copy): Add _MoveValues template parameter.
	* testsuite/23_containers/map/allocator/move_cons.cc: New test.
	* testsuite/23_containers/multimap/allocator/move_cons.cc: New test.
	* testsuite/23_containers/multiset/allocator/move_cons.cc: New test.
	* testsuite/23_containers/set/allocator/move_cons.cc: New test.
2020-11-20 20:56:10 +01:00
Jonathan Wakely
640ebeb336 libstdc++: Remove <memory_resource> dependency from <regex> [PR 92546]
Unlike the other headers that declare alias templates in namespace pmr,
<regex> includes <memory_resource>. That was done because the
pmr::string::const_iterator typedef requires pmr::string to be complete,
which requires pmr::polymorphic_allocator<char> to be complete.

By using __normal_iterator<const char*, pmr::string> instead of the
const_iterator typedef we can avoid the completeness requirement.

This makes <regex> smaller, by not requiring <memory_resource> and its
<shared_mutex> dependency, which depends on <chrono>.  Backporting this
will also help with PR 97876, where <stop_token> ends up being needed by
<regex> via <memory_resource>.

libstdc++-v3/ChangeLog:

	PR libstdc++/92546
	* include/std/regex (pmr::smatch, pmr::wsmatch): Declare using
	underlying __normal_iterator type, not nested typedef
	basic_string::const_iterator.
2020-11-20 13:06:48 +00:00
GCC Administrator
d62586ee56 Daily bump. 2020-11-20 00:16:40 +00:00
Jonathan Wakely
08b4d32571 libstdc++: Avoid calling undefined __gthread_self weak symbol [PR 95989]
Since glibc 2.27 the pthread_self symbol has been defined in libc rather
than libpthread. Because we only call pthread_self through a weak alias
it's possible for statically linked executables to end up without a
definition of pthread_self. This crashes when trying to call an
undefined weak symbol.

We can use the __GLIBC_PREREQ version check to detect the version of
glibc where pthread_self is no longer in libpthread, and call it
directly rather than through the weak reference.

It would be better to check for pthread_self in libc during configure
instead of hardcoding the __GLIBC_PREREQ check. That would be
complicated by the fact that prior to glibc 2.27 libc.a didn't have the
pthread_self symbol, but libc.so.6 did.  The configure checks would need
to try to link both statically and dynamically, and the result would
depend on whether the static libc.a happens to be installed during
configure (which could vary between different systems using the same
version of glibc). Doing it properly is left for a future date, as that
will be needed anyway after glibc moves all pthread symbols from
libpthread to libc. When that happens we should revisit the whole
approach of using weak symbols for pthread symbols.

For the purposes of std::this_thread::get_id() we call
pthread_self() directly when using glibc 2.27 or later. Otherwise, if
__gthread_active_p() is true then we know the libpthread symbol is
available so we call that. Otherwise, we are single-threaded and just
use ((__gthread_t)1) as the thread ID.

An undesirable consequence of this change is that code compiled prior to
the change might inline the old definition of this_thread::get_id()
which always returns (__gthread_t)1 in a program that isn't linked to
libpthread. Code compiled after the change will use pthread_self() and
so get a real TID. That could result in the main thread having different
thread::id values in different translation units. This seems acceptable,
as there are not expected to be many uses of thread::id in programs
that aren't linked to libpthread.

An earlier version of this patch also changed __gthread_self() to use
__GLIBC_PREREQ(2, 27) and only use the weak symbol for older glibc. Tha
might still make sense to do, but isn't needed by libstdc++ now.

libstdc++-v3/ChangeLog:

	PR libstdc++/95989
	* config/os/gnu-linux/os_defines.h (_GLIBCXX_NATIVE_THREAD_ID):
	Define new macro to get reliable thread ID.
	* include/bits/std_thread.h: (this_thread::get_id): Use new
	macro if it's defined.
	* testsuite/30_threads/jthread/95989.cc: New test.
	* testsuite/30_threads/this_thread/95989.cc: New test.
2020-11-19 21:07:06 +00:00
Jonathan Wakely
5e6a43158d libstdc++: Add missing header to some tests
These tests use std::this_thread::sleep_for without including <thread>.

libstdc++-v3/ChangeLog:

	* testsuite/30_threads/async/async.cc: Include <thread>.
	* testsuite/30_threads/future/members/93456.cc: Likewise.
2020-11-19 16:17:33 +00:00
Jonathan Wakely
b204d7722d libstdc++: Move std::thread to a new header
This makes it possible to use std::thread without including the whole of
<thread>. It also makes this_thread::get_id() and this_thread::yield()
available even when there is no gthreads support (e.g. when GCC is built
with --disable-threads or --enable-threads=single).

In order for the std:🧵:id return type of this_thread::get_id() to
be defined, std:thread itself is defined unconditionally. However the
constructor that creates new threads is not defined for single-threaded
builds. The thread::join() and thread::detach() member functions are
defined inline for single-threaded builds and just throw an exception
(because we know the thread cannot be joinable if the constructor that
creates joinable threads doesn't exit).

The thread::hardware_concurrency() member function is also defined
inline and returns 0 (as suggested by the standard when the value "is
not computable or well-defined").

The main benefit for most targets is that other headers such as <future>
do not need to include the whole of <thread> just to be able to create a
std::thread. That avoids including <stop_token> and std::jthread where
not required. This is another partial fix for PR 92546.

This also means we can use this_thread::get_id() and this_thread::yield()
in <stop_token> instead of using the gthread functions directly. This
removes some preprocessor conditionals, simplifying the code.

libstdc++-v3/ChangeLog:

	PR libstdc++/92546
	* include/Makefile.am: Add new <bits/std_thread.h> header.
	* include/Makefile.in: Regenerate.
	* include/std/future: Include new header instead of <thread>.
	* include/std/stop_token: Include new header instead of
	<bits/gthr.h>.
	(stop_token::_S_yield()): Use this_thread::yield().
	(_Stop_state_t::_M_requester): Change type to std:🧵:id.
	(_Stop_state_t::_M_request_stop()): Use this_thread::get_id().
	(_Stop_state_t::_M_remove_callback(_Stop_cb*)): Likewise.
	Use __is_single_threaded() to decide whether to synchronize.
	* include/std/thread (thread, operator==, this_thread::get_id)
	(this_thread::yield): Move to new header.
	(operator<=>, operator!=, operator<, operator<=, operator>)
	(operator>=, hash<thread::id>, operator<<): Define even when
	gthreads not available.
	* src/c++11/thread.cc: Include <memory>.
	* include/bits/std_thread.h: New file.
	(thread, operator==, this_thread::get_id, this_thread::yield):
	Define even when gthreads not available.
	[!_GLIBCXX_HAS_GTHREADS] (thread::join, thread::detach)
	(thread::hardware_concurrency): Define inline.
2020-11-19 13:36:15 +00:00
Jonathan Wakely
b108faa940 libstdc++: Fix overflow checks to use the correct "time_t" [PR 93456]
I recently added overflow checks to src/c++11/futex.cc for PR 93456, but
then changed the type of the timespec for PR 93421. This meant the
overflow checks were no longer using the right range, because the
variable being written to might be smaller than time_t.

This introduces new typedef that corresponds to the tv_sec member of the
struct being passed to the syscall, and uses that typedef in the range
checks.

libstdc++-v3/ChangeLog:

	PR libstdc++/93421
	PR libstdc++/93456
	* src/c++11/futex.cc (syscall_time_t): New typedef for
	the type of the syscall_timespec::tv_sec member.
	(relative_timespec, _M_futex_wait_until)
	(_M_futex_wait_until_steady): Use syscall_time_t in overflow
	checks, not time_t.
2020-11-19 13:33:11 +00:00
GCC Administrator
25bb75f841 Daily bump. 2020-11-19 00:16:30 +00:00
Patrick Palka
d4a788c717 libstdc++: Fix ranges::join_view::_Iterator::operator-> [LWG 3500]
This applies the proposed resolution of LWG 3500, which corrects the
return type and constraints of this member function to use the right
iterator type.  Additionally, a nearby local variable is uglified.

libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view::_Iterator::_M_satisfy): Uglify
	local variable inner.
	(join_view::_Iterator::operator->): Use _Inner_iter instead of
	_Outer_iter in the function signature as per LWG 3500.
	* testsuite/std/ranges/adaptors/join.cc (test08): Test it.
2020-11-18 10:23:57 -05:00
GCC Administrator
4dabb03719 Daily bump. 2020-11-18 00:16:34 +00:00
Jonathan Wakely
1e3e6c700f libstdc++: Revert changes for SYS_clock_gettime64 [PR 93421]
As discussed in the PR, it's incredibly unlikely that a system that
needs to use the SYS_clock_gettime syscall (e.g. glibc 2.16 or older) is
going to define the SYS_clock_gettime64 macro. Ancient systems that need
to use the syscall aren't going to have time64 support.

This reverts the recent changes to try and make clock_gettime syscalls
be compatible with systems that have been updated for time64 (those
changes were wrong anyway as they misspelled the SYS_clock_gettime64
macro). The changes for futex syscalls are retained, because we still
use them on modern systems that might be using time64.

To ensure that the clock_gettime syscalls are safe, configure will fail
if SYS_clock_gettime is needed, and SYS_clock_gettime64 is also defined
(but to a distinct value from SYS_clock_gettime), and the tv_sec member
of timespec is larger than long. This means we will be unable to build
on a hypothetical system where we need the time32 version of
SYS_clock_gettime but where userspace is using a time64 struct timespec.
In the unlikely event that this failure is triggered on any real
systems, we can fix it later. But we probably won't need to.

libstdc++-v3/ChangeLog:

	PR libstdc++/93421
	* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): Fail if struct
	timespec isn't compatible with SYS_clock_gettime.
	* configure: Regenerate.
	* src/c++11/chrono.cc: Revert changes for time64 compatibility.
	Add static_assert instead.
	* src/c++11/futex.cc (_M_futex_wait_until_steady): Assume
	SYS_clock_gettime can use struct timespec.
2020-11-17 22:38:49 +00:00
Jonathan Wakely
ecf65330c1 libstdc++: Fix unconditional definition of __cpp_lib_span in <version> [PR 97869}
The <span> header is empty unless Concepts are supported, but <version>
defines the __cpp_lib_span feature test macro unconditionally. It should
be guarded by the same conditions as in <span>.

libstdc++-v3/ChangeLog:

	PR libstdc++/97869
	* include/precompiled/stdc++.h: Include <coroutine>.
	* include/std/version (__cpp_lib_span): Check __cpp_lib_concepts
	before defining.
2020-11-17 16:13:14 +00:00
Patrick Palka
8661f4faa8 libstdc++: Fix ranges::search_n for random access iterators [PR97828]
My ranges transcription of the std::search_n implementation for random
access iterators missed a crucial part of the algorithm which the
existing tests didn't exercise.  When __remainder is less than __count
at the start of an iteration of the outer while loop, it means we're
continuing a partial match of __count - __remainder elements from the
previous iteration.  If at the end of the iteration we don't complete
this partial match, we need to reset __remainder so that it's only
offset by the size of the most recent partial match before starting the
next iteration.

This patch fixes this appropriately, mirroring how it's done in the
corresponding std::search_n implementation.

libstdc++-v3/ChangeLog:

	PR libstdc++/97828
	* include/bits/ranges_algo.h (__search_n_fn::operator()): Check
	random_access_iterator before using the backtracking
	implementation.  When the backwards scan fails prematurely,
	reset __remainder appropriately.
	* testsuite/25_algorithms/search_n/97828.cc: New test.
2020-11-17 10:28:20 -05:00
GCC Administrator
29c5d9ceb9 Daily bump. 2020-11-17 00:16:27 +00:00
Jonathan Wakely
b2099e9fd9 libstdc++: Fix error shown during Solaris build
Currently this is shown when building libstdc++ on Solaris:

-lrt: open: No such file or directory

The error comes from the make_sunver.pl script which tries to open each
of its arguments. The arguments are passed by this make rule:

	perl ${glibcxx_srcdir}/scripts/make_exports.pl \
	  libstdc++-symbols.ver \
	  $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
	 `echo $(libstdc___la_LIBADD) | \
	    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
	 > $@ || (rm -f $@ ; exit 1)

The $(libstdc___la_LIBADD) variable includes $(GLIBCXX_LIBS) which
contains -lrt on Solaris.

This patch adds another sed script to filter -l arguments from the echo
command. In order to reliably match ' -l[^ ]* ' the echo arguments are
quoted and a space added before and after them. This might be overkill
just to remove -lrt from the start of the string, but should be robust
in case other -l arguments are added to $(GLIBCXX_LIBS), or in case the
$(libstdc___la_LIBADD) libraries are reordered.

libstdc++-v3/ChangeLog:

	* src/Makefile.am (libstdc++-symbols.ver-sun): Remove -lrt from
	arguments passed to make_sunver.pl script.
	* src/Makefile.in: Regenerate.
2020-11-16 11:54:22 +00:00
GCC Administrator
cba306519c Daily bump. 2020-11-16 00:16:31 +00:00
Jason Merrill
baf38d2e36 c++: Check abstract type only on object creation. [PR86252]
Abstract checking has been problematic for a while; when I implemented an
earlier issue resolution to do more checking it led to undesirable
instantiations, and so backed some of it out.  During the C++20 process we
decided with P0929R2 that we should go the other way, and only check
abstractness when we're actually creating an object, not when merely forming
an array or function type.  This means that we can remove the machinery for
checking whether a newly complete class makes some earlier declaration
ill-formed.  This change was moved as a DR, so I'm applying it to all
standard levels.  This could be reconsidered if it causes problems, but I
don't expect it to.

The change to the libstdc++ result_of test brings the expected behavior in
line with that for incomplete types, but as in PR97841 I think the libstdc++
handling of incomplete types in this and other type_traits is itself wrong,
so I expect these lines and others to change again before long.

gcc/cp/ChangeLog:

	* decl.c (cp_finish_decl): Only check abstractness on definition.
	(require_complete_types_for_parms): Check abstractness here.
	(create_array_type_for_decl): Not here.
	(grokdeclarator, grokparms, complete_vars): Not here.
	* pt.c (tsubst, tsubst_arg_types, tsubst_function_type): Not here.
	* typeck2.c (struct pending_abstract_type): Remove.
	(struct abstract_type_hasher): Remove.
	(abstract_pending_vars, complete_type_check_abstract): Remove.
	(abstract_virtuals_error_sfinae): Handle arrays.
	* call.c (conv_is_prvalue): Split out from...
	(conv_binds_ref_to_prvalue): ...here.
	(implicit_conversion_1): Rename from implicit_conversion.
	(implicit_conversion): An abstract prvalue is bad.
	(convert_like_internal): Don't complain if expr is already
	error_mark_node.

gcc/testsuite/ChangeLog:

	* g++.dg/other/abstract1.C: Adjust.
	* g++.dg/other/abstract2.C: Adjust.
	* g++.dg/other/abstract4.C: Adjust.
	* g++.dg/other/abstract5.C: Adjust.
	* g++.dg/other/abstract8.C: New test.
	* g++.dg/template/sfinae-dr657.C: Adjust.
	* g++.old-deja/g++.other/decl3.C: Adjust.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/result_of/sfinae_friendly_1.cc: Adjust.
2020-11-15 12:07:13 -05:00
GCC Administrator
77f67db2a4 Daily bump. 2020-11-14 00:16:38 +00:00
Jonathan Wakely
4d039cb9a1 libstdc++: Use custom timespec in system calls [PR 93421]
On 32-bit targets where userspace has switched to 64-bit time_t, we
cannot pass struct timespec to SYS_futex or SYS_clock_gettime, because
the userspace definition of struct timespec will not match what the
kernel expects.

We use the existence of the SYS_futex_time64 or SYS_clock_gettime_time64
macros to imply that userspace *might* have switched to the new timespec
definition.  This is a conservative assumption. It's possible that the
new syscall numbers are defined in the libc headers but that timespec
hasn't been updated yet (as is the case for glibc currently). But using
the alternative struct with two longs is still OK, it's just redundant
if userspace timespec still uses a 32-bit time_t.

We also check that SYS_futex_time64 != SYS_futex so that we don't try
to use a 32-bit tv_sec on modern targets that only support the 64-bit
system calls and define the old macro to the same value as the new one.

We could possibly check #ifdef __USE_TIME_BITS64 to see whether
userspace has actually been updated, but it's not clear if user code
is meant to inspect that or if it's only for libc internal use.

libstdc++-v3/ChangeLog:

	PR libstdc++/93421
	* src/c++11/chrono.cc [_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL]
	(syscall_timespec): Define a type suitable for SYS_clock_gettime
	calls.
	(system_clock::now(), steady_clock::now()): Use syscall_timespec
	instead of timespec.
	* src/c++11/futex.cc (syscall_timespec): Define a type suitable
	for SYS_futex and SYS_clock_gettime calls.
	(relative_timespec): Use syscall_timespec instead of timespec.
	(__atomic_futex_unsigned_base::_M_futex_wait_until): Likewise.
	(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
	Likewise.
2020-11-13 23:08:35 +00:00
Jonathan Wakely
b8d36dcc91 libstdc++: Remove redundant overflow check for futex timeout [PR 93456]
The relative_timespec function already checks for the case where the
specified timeout is in the past, so the difference can never be
negative. That means we dn't need to check if it's more negative than
the minimum time_t value.

libstdc++-v3/ChangeLog:

	PR libstdc++/93456
	* src/c++11/futex.cc (relative_timespec): Remove redundant check
	negative values.
	* testsuite/30_threads/future/members/wait_until_overflow.cc: Moved to...
	* testsuite/30_threads/future/members/93456.cc: ...here.
2020-11-13 23:08:34 +00:00
Jonathan Wakely
91004436da libstdc++: Avoid more 32-bit time_t overflows in futex calls
This fixes another overflow in code converting a std::chrono::seconds
duration to a time_t. This time in the new code using a futex wait with
an absolute timeout (so this one doesn't need to be backported to the
release branches).

A timeout after the epochalypse would overflow the tv_sec field,
producing an incorrect value. If that incorrect value happened to be
negative, the syscall would return with EINVAL and then the caller would
keep retrying, spinning until the timeout was reached.  If the value
happened to be positive, we would wake up too soon and incorrectly
report a timeout

libstdc++-v3/ChangeLog:

	* src/c++11/futex.cc (relative_timespec): Add [[unlikely]]
	attributes.
	(__atomic_futex_unsigned_base::_M_futex_wait_until)
	(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
	Check for overflow.
	* testsuite/30_threads/future/members/wait_until_overflow.cc:
	New test.
2020-11-13 19:11:07 +00:00
Jonathan Wakely
e7e0eeeb6e libstdc++: Avoid 32-bit time_t overflows in futex calls
The existing code doesn't check whether the chrono::seconds value is out
of range of time_t. When using a timeout before the epoch (with a
negative value) subtracting the current time (as time_t) and then
assigning it to a time_t can overflow to a large positive value. This
means that we end up waiting several years even though the specific
timeout was in the distant past.

We do have a check for negative timeouts, but that happens after the
conversion to time_t so happens after the overflow.

The conversion to a relative timeout is done in two places, so this
factors it into a new function and adds the overflow checks there.

libstdc++-v3/ChangeLog:

	* src/c++11/futex.cc (relative_timespec): New function to
	create relative time from two absolute times.
	(__atomic_futex_unsigned_base::_M_futex_wait_until)
	(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
	Use relative_timespec.
2020-11-13 17:19:12 +00:00
Jonathan Wakely
8c4e33d203 libstdc++: Add -pthread options to std::future polling test
For linux targets this test doesn't need -lpthread because it only uses
atomics, but for all other targets std::call_once still needs pthreads.
Add the necessary test directives to make that work.

The timings in this test might be too fragile or too target-specific, so
it might need to be adjusted in future, or restricted to only run on
specific targets. For now I've increased the allowed ratio between
wait_for calls before and after the future is made ready, because it was
failing with -O3 -march=native sometimes.

libstdc++-v3/ChangeLog:

	* testsuite/30_threads/future/members/poll.cc: Require gthreads
	and add -pthread for targets that require it. Relax required
	ratio of wait_for calls before/after the future is ready.
2020-11-13 11:01:24 +00:00
GCC Administrator
a5a115258a Daily bump. 2020-11-13 00:16:35 +00:00
Jonathan Wakely
93fc477468 libstdc++: Optimise std::future::wait_for and fix futex polling
To poll a std::future to see if it's ready you have to call one of the
timed waiting functions. The most obvious way is wait_for(0s) but this
was previously very inefficient because it would turn the relative
timeout to an absolute one by calling system_clock::now(). When the
relative timeout is zero (or less) we're obviously going to get a time
that has already passed, but the overhead of obtaining the current time
can be dozens of microseconds. The alternative is to call wait_until
with an absolute timeout that is in the past. If you know the clock's
epoch is in the past you can use a default constructed time_point.
Alternatively, using some_clock::time_point::min() gives the earliest
time point supported by the clock, which should be safe to assume is in
the past. However, using a futex wait with an absolute timeout before
the UNIX epoch fails and sets errno=EINVAL. The new code using futex
waits with absolute timeouts was not checking for this case, which could
result in hangs (or killing the process if the libray is built with
assertions enabled).

This patch checks for times before the epoch before attempting to wait
on a futex with an absolute timeout, which fixes the hangs or crashes.
It also makes it very fast to poll using an absolute timeout before the
epoch (because we skip the futex syscall).

It also makes future::wait_for avoid waiting at all when the relative
timeout is zero or less, to avoid the unnecessary overhead of getting
the current time. This makes polling with wait_for(0s) take only a few
cycles instead of dozens of milliseconds.

libstdc++-v3/ChangeLog:

	* include/std/future (future::wait_for): Do not wait for
	durations less than or equal to zero.
	* src/c++11/futex.cc (_M_futex_wait_until)
	(_M_futex_wait_until_steady): Do not wait for timeouts before
	the epoch.
	* testsuite/30_threads/future/members/poll.cc: New test.
2020-11-12 23:47:04 +00:00
Jonathan Wakely
d21776ef90 libstdc++: Simplify __numeric_traits definition
This changes the __numeric_traits primary template to assume its
argument is an integer type. For the three floating point types that are
supported by __numeric_traits_floating an explicit specialization of
__numeric_traits chooses the right base class.

This improves the failure mode for using __numeric_traits with an
unsupported type. Previously it would use __numeric_traits_floating as
the base class, and give somewhat obscure errors for trying to access
the static data members. Now it will use __numeric_traits_integer which
has a static_assert to check for supported types.

As a side effect of this change there is no need to instantiate
__conditional_type to decide which base class to use.

libstdc++-v3/ChangeLog:

	* include/ext/numeric_traits.h (__numeric_traits): Change
	primary template to always derive from __numeric_traits_integer.
	(__numeric_traits<float>, __numeric_traits<double>)
	(__numeric_traits<long double>): Add explicit specializations.
2020-11-12 14:36:39 +00:00
Jonathan Wakely
7f851c3341 libstdc++: Fix __numeric_traits_integer<__int20> [PR 97798]
The expression used to calculate the maximum value for an integer type
assumes that the number of bits in the value representation is always
sizeof(T) * CHAR_BIT. This is not true for the __int20 type on msp430,
which has only 20 bits in the value representation but 32 bits in the
object representation. This causes an integer overflow in a constant
expression, which is ill-formed.

This problem was already solved by DJ for std::numeric_limits<__int20>
by generalizing the helper macros to use a specified number of bits
instead of assuming sizeof(T) * CHAR_BIT. Then the INT_N_n types can
specify the number of bits using the __GLIBCXX_BITSIZE_INT_N_n macros
that the compiler defines.

I'm using a slightly different approach here. I've replaced the helper
macros entirely, and just expanded the calculations in the initializers
for the static data members. By reordering the data members we can reuse
__is_signed and __digits in the other initializers. This removes the
repetition of expanding __glibcxx_signed(T) and __glibcxx_digits(T)
multiple times in each initializer.

The __is_integer_nonstrict trait now defines a new constant, __width,
which is sizeof(T) * CHAR_BIT by default (defined as an enumerator so
that no storage is needed for a static data member). By specializing
__is_integer_nonstrict for the INT_N types that have padding bits, we
can provide the correct width via the __GLIBCXX_BITSIZE_INT_N_n macros.

libstdc++-v3/ChangeLog:

	PR libstdc++/97798
	* include/ext/numeric_traits.h (__glibcxx_signed)
	(__glibcxx_digits, __glibcxx_min, __glibcxx_max): Remove
	macros.
	(__is_integer_nonstrict::__width): Define new constant.
	(__numeric_traits_integer): Define constants in terms of each
	other and __is_integer_nonstrict::__width, rather than the
	removed macros.
	(_GLIBCXX_INT_N_TRAITS): Macro to define explicit
	specializations for non-standard integer types.
2020-11-12 12:10:10 +00:00
GCC Administrator
0f5f9ed5e5 Daily bump. 2020-11-12 00:16:39 +00:00
Jonathan Yong
505ea90904 libstdc++: Exclude cygwin and mingw from linker relro support
PE format does not have ELF style relro linker support, exclude
from checking. If the host linker supports ELF format, configure
may get confused.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Exclude
	cygwin and mingw from relro linker test.
	* configure: Regenerate.
2020-11-11 15:36:05 +00:00
Paul Scharnofske
0ebaea3b66 libstdc++: Assigning to a joinable std::jthread calls std::terminate
Move assigning to a std::jthread that represents a thread of execution
needs to send a stop request and join that running thread. Otherwise the
std::thread data member will terminate in its assignment operator.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/thread (jthread::operator=(jthread&&)): Transfer
	any existing state to a temporary that will request a stop and
	then join.
	* testsuite/30_threads/jthread/jthread.cc: Test move assignment.
2020-11-11 11:13:31 +00:00
Jonathan Wakely
43f9e5aff0 libstdc++: Use helper type for checking thread ID
This encapsulates the storing and checking of the thread ID into a class
type, so that the macro _GLIBCXX_HAS_GTHREADS is only checked in one
place. The code doing the checks just calls member functions of the new
type, without caring whether that really does any work or not.

libstdc++-v3/ChangeLog:

	* include/std/stop_token (_Stop_state_t::_M_requester): Define
	new struct with members to store and check the thread ID.
	(_Stop_state_t::_M_request_stop()): Use _M_requester._M_set().
	(_Stop_state_t::_M_remove_callback(_Stop_cb*)): Use
	_M_requester._M_is_current_thread().
2020-11-11 11:13:31 +00:00
Jonathan Wakely
ecba8547dd libstdc++: Implement std::emit_on_flush etc.
This adds the manipulators for use with basic_osyncstream. In order to
detect when an arbitrary basic_ostream<C,T> is the base class of a
basic_syncbuf<C,T,A> object, introduce a new intermediate base class
that stores the data members. The new base class stores a pointer and
two bools, which wastes (sizeof(void*) - 2) bytes of padding. It would
be possible to use the two least significant bits of the pointer for the
two bools, at least for targets where alignof(basic_streambuf) > 2, but
that's left as a possible change for a future date.

Also define basic_syncbuf::overflow to override the virtual function in
the base class, so that single characters can be inserted into the
stream buffer. Previously the default basic_streambuf::overflow
implementation was used, which drops the character on the floor.

libstdc++-v3/ChangeLog:

	* include/std/ostream (__syncbuf_base): New class template.
	(emit_on_flush, noemit_on_flush, flush_emit): New manipulators.
	* include/std/syncstream (basic_syncbuf): Derive from
	__syncbuf_base instead of basic_streambuf.
	(basic_syncbuf::operator=): Remove self-assignment check.
	(basic_syncbuf::swap): Remove self-swap check.
	(basic_syncbuf::emit): Do not skip pubsync() call if sequence
	is empty.
	(basic_syncbuf::sync): Remove no-op pubsync on stringbuf.
	(basic_syncbuf::overflow): Define override.
	* testsuite/27_io/basic_syncstream/basic_ops/1.cc: Test
	basic_osyncstream::put(char_type).
	* testsuite/27_io/basic_ostream/emit/1.cc: New test.
2020-11-11 00:19:40 +00:00
GCC Administrator
bb6226419f Daily bump. 2020-11-11 00:16:36 +00:00
Jonathan Wakely
5dfbc52264 libstdc++: Avoid bad_alloc exceptions when changing locales
For the --enable-clocale=generic configuration, the current code can
fail with a bad_alloc exception. This patch uses the nothrow version of
operator new and reports allocation failures by setting failbit in the
iostate variable.

	* config/locale/generic/c_locale.cc (__set_C_locale()): New function
	to set the "C" locale and return the name of the previous locale.
	(__convert_to_v<float>, __convert_to_v<double>)
	(__convert_to_v<long double>): Use __set_C_locale and set failbit on
	error.
2020-11-10 20:33:29 +00:00
Jonathan Wakely
f7c41c572b libstdc++: Reorder constructors in <sstream>
This groups all the constructors together, consistent with the synopses
in the C++20 standard.

libstdc++-v3/ChangeLog:

	* include/std/sstream (basic_stringbug, basic_istringstream)
	(basic_ostringstream, basic_stringstream): Reorder C++20
	constructors to be declared next to other constructors.
2020-11-10 19:22:48 +00:00
Jonathan Wakely
95cb0fc8c5 libstdc++: Add remaining C++20 additions to <sstream> [P0408R7]
This adds the new overloads of basic_stringbuf::str, and the
corresponding overloads to basic_istringstream, basic_ostringstream and
basic_stringstream.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Tighten patterns.
	(GLIBCXX_3.4.29): Export new symbols.
	* include/bits/alloc_traits.h (__allocator_like): New concept.
	* include/std/sstream (basic_stringbuf::swap): Add exception
	specification.
	(basic_stringbuf::str() const): Add ref-qualifier. Use new
	_M_high_mark function.
	(basic_stringbuf::str(const SAlloc&) const): Define new function.
	(basic_stringbuf::str() &&): Likewise.
	(basic_stringbuf::str(const basic_string<C,T,SAlloc>&)):
	Likewise.
	(basic_stringbuf::str(basic_string<C,T,Alloc>&&)): Likewise.
	(basic_stringbuf::view() const): Use _M_high_mark.
	(basic_istringstream::str, basic_ostringstream::str)
	(basic_stringstream::str): Define new overloads.
	* src/c++20/sstream-inst.cc (basic_stringbuf::str)
	(basic_istringstream::str, basic_ostringstream::str)
	(basic_stringstream::str): Explicit instantiation definitions
	for new overloads.
	* testsuite/27_io/basic_istringstream/view/char/1.cc: Add more
	checks.
	* testsuite/27_io/basic_istringstream/view/wchar_t/1.cc:
	Likewise.
	* testsuite/27_io/basic_ostringstream/view/char/1.cc:
	Likewise.
	* testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc:
	Likewise.
	* testsuite/27_io/basic_stringstream/view/char/1.cc:
	Likewise.
	* testsuite/27_io/basic_stringstream/view/wchar_t/1.cc:
	Likewise.
	* testsuite/27_io/basic_istringstream/str/char/2.cc: New test.
	* testsuite/27_io/basic_istringstream/str/wchar_t/2.cc: New test.
	* testsuite/27_io/basic_ostringstream/str/char/3.cc: New test.
	* testsuite/27_io/basic_ostringstream/str/wchar_t/3.cc: New test.
	* testsuite/27_io/basic_stringbuf/str/char/4.cc: New test.
	* testsuite/27_io/basic_stringbuf/str/wchar_t/4.cc: New test.
	* testsuite/27_io/basic_stringstream/str/char/5.cc: New test.
	* testsuite/27_io/basic_stringstream/str/wchar_t/5.cc.cc: New test.
2020-11-10 19:22:47 +00:00
Jonathan Wakely
ced70ebaa3 libstdc++: Fix more unspecified comparisons to null pointer [PR 97415]
This adds some more null checks to avoid a relational comparison with a
null pointer, similar to 78198b6021.

libstdc++-v3/ChangeLog:

	PR libstdc++/97415
	* include/std/sstream (basic_stringbuf::_M_update_egptr)
	(basic_stringbuf::__xfer_bufptrs::__xfer_bufptrs): Check for
	null before comparing pointers.
2020-11-10 19:21:55 +00:00
GCC Administrator
2bee28dd41 Daily bump. 2020-11-10 00:16:24 +00:00
François Dumont
6db082477a libstdc++: Remove <debug/array>
Add _GLIBCXX_ASSERTIONS assert in normal std::array and remove __gnu_debug::array
implementation.

libstdc++-v3/ChangeLog:

	* include/debug/array: Remove.
	* include/Makefile.am: Remove <debug/array>.
	* include/Makefile.in: Regenerate.
	* include/experimental/functional: Adapt.
	* include/std/array: Move to _GLIBCXX_INLINE_VERSION namespace.
	* include/std/functional: Adapt.
	* include/std/span: Adapt.
	* testsuite/23_containers/array/debug/back1_neg.cc:
	Remove dg-require-debug-mode. Add -D_GLIBCXX_ASSERTIONS option.
	* testsuite/23_containers/array/debug/back2_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/front1_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/front2_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc:
	Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc:
	Likewise.
	* testsuite/23_containers/array/element_access/60497.cc
	* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc:
	Remove.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc
	* testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc
	* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
2020-11-09 21:20:01 +01:00
François Dumont
38b17c27ce libstdc++: Make _GLIBCXX_DEBUG checks constexpr compatible
libstdc++-v3/ChangeLog:

	* include/debug/assertions.h (__glibcxx_requires_non_empty_range):
	Remove __builtin_expect.
	(__glibcxx_requires_subscript): Likewise.
	(__glibcxx_requires_nonempty): Likewise.
	* include/debug/formatter.h (__check_singular): Add C++11 constexpr
	qualification.
	* include/debug/helper_functions.h (__check_singular): Likewise. Skip
	check if constant evaluated.
	(__valid_range): Do not skip check if constant evaluated.
	* include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_COND_AT): Add
	__builtin_expect.
	(_GLIBCXX_DEBUG_VERIFY_AT_F): Use __glibcxx_assert_1.
	* testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc:
	New test.
	* testsuite/21_strings/basic_string_view/element_access/char/constexpr.cc: New test.
	* testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc: New test.
	* testsuite/21_strings/basic_string_view/element_access/char/front_back_constexpr.cc:
	New test.
	* testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc:
	New test.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc:
	New test.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr.cc: New test.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc: New test.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc:
	New test.
	* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_neg.cc: New test.
	* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_pred_neg.cc: New test.
	* testsuite/25_algorithms/lower_bound/debug/constexpr_valid_range_neg.cc: New test.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_neg.cc: New test.
	* testsuite/25_algorithms/lower_bound/debug/partitioned_pred_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_pred_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/constexpr_valid_range_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_neg.cc: New test.
	* testsuite/25_algorithms/upper_bound/debug/partitioned_pred_neg.cc: New test.
2020-11-09 21:11:13 +01:00
Jonathan Wakely
b2b8516373 libstdc++: Improve comment on _Power_of_2 helper function
libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (__detail::_Power_of_2):
	Document that true result for zero is intentional.
2020-11-09 14:54:29 +00:00
Jonathan Wakely
ff4bfb1553 libstdc++: Remove redundant check for zero in std::__popcount
The popcount built-ins work fine for zero, so there's no need to check
for it.

libstdc++-v3/ChangeLog:

	* include/std/bit (__popcount): Remove redundant check for zero.
2020-11-09 14:54:29 +00:00
Jonathan Wakely
0af3930a49 libstdc++: Use 'inline' consistently in std::exception_ptr [PR 97729]
With PR c++/67453 fixed we can rely on the 'used' attribute to emit
inline constructors and destructors in libsupc++/eh_ptr.cc. This means
we don't need to suppress the 'inline' keyword on them in that file, and
don't need to force 'always_inline' on them in other files.

libstdc++-v3/ChangeLog:

	PR libstdc++/97729
	* libsupc++/exception_ptr.h (exception_ptr::exception_ptr())
	(exception_ptr::exception_ptr(const exception_ptr&))
	(exception_ptr::~exception_ptr()): Remove 'always_inline'
	attributes. Use 'inline' unconditionally.
2020-11-09 14:28:38 +00:00
Jonathan Wakely
99bf3a817b libstdc++: Include <typeinfo> even for -fno-rtti [PR 97758]
The std::function code now uses std::type_info* even when RTTI is
disabled, so it should include <typeinfo> unconditionally. Without this,
Clang can't compile <functional> with -fno-rtti (it works with GCC
because std::type_info gets declared automatically by the compiler).

libstdc++-v3/ChangeLog:

	PR libstdc++/97758
	* include/bits/std_function.h [!__cpp_rtti]: Include <typeinfo>.
2020-11-09 14:28:37 +00:00
GCC Administrator
2da7ee050c Daily bump. 2020-11-08 00:16:31 +00:00
Liu Hao
7fc0f78c3f libsupc++: Make the destructor parameter to __cxa_thread_atexit() use the __thiscall calling convention for i686-w64-mingw32
The mingw-w64 implementations of `__cxa_thread_atexit()` and `__cxa_atexit()` have been
using `__thiscall` since two years ago. Using the default calling convention (which is
`__cdecl`) causes crashes as explained in PR83562.

Calling conventions have no effect on x86_64-w64-mingw32.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83562
Reference: https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/crt/cxa_thread_atexit.c
Reference: f3e0fbb40c/
Reference: https://github.com/msys2/MINGW-packages/issues/7071
Signed-off-by: Liu Hao <lh_mouse@126.com>

    2020-10-08  Liu Hao  <lh_mouse@126.com>

	libstdc++-v3:
	* libsupc++/cxxabi.h: (__cxa_atexit): mark with _GLIBCXX_CDTOR_CALLABI
	(__cxa_thread_atexit): ditto
	* libsupc++/atexit_thread.cc: (__cxa_atexit): mark with
	_GLIBCXX_CDTOR_CALLABI
	(__cxa_thread_atexit): ditto
	(elt): ditto
2020-11-07 02:50:43 +00:00
GCC Administrator
44cab2d8fd Daily bump. 2020-11-07 00:16:39 +00:00
Jonathan Wakely
887515acd2 libstdc++: Fix symbol version conflict in linker script
The change in r11-4748-50b840ac5e1d6534e345c3fee9a97ae45ced6bc7 causes
a build error on Solaris, due to the new explicit instantiation matching
patterns for two different symbol versions.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Tighten up patterns
	for basic_stringbuf that refer to __xfer_bufptrs.
2020-11-06 20:14:03 +00:00
GCC Administrator
0cfd9109e5 Daily bump. 2020-11-06 00:16:34 +00:00
Marek Polacek
5b2003105b c++: Implement -Wvexing-parse [PR25814]
This patch implements the -Wvexing-parse warning to warn about the
sneaky most vexing parse rule in C++: the cases when a declaration
looks like a variable definition, but the C++ language requires it
to be interpreted as a function declaration.  This warning is on by
default (like clang++).  From the docs:

  void f(double a) {
    int i();        // extern int i (void);
    int n(int(a));  // extern int n (int);
  }

  Another example:

  struct S { S(int); };
  void f(double a) {
    S x(int(a));   // extern struct S x (int);
    S y(int());    // extern struct S y (int (*) (void));
    S z();         // extern struct S z (void);
  }

You can find more on this in [dcl.ambig.res].

I spent a fair amount of time on fix-it hints so that GCC can recommend
various ways to resolve such an ambiguity.  Sometimes that's tricky.
E.g., suggesting default-initialization when the class doesn't have
a default constructor would not be optimal.  Suggesting {}-init is also
not trivial because it can use an initializer-list constructor if no
default constructor is available (which ()-init wouldn't do).  And of
course, pre-C++11, we shouldn't be recommending {}-init at all.

I also uncovered a bug in cp_parser_declarator, where we were setting
*parenthesized_p to true despite the comment saying the exact opposite.

gcc/c-family/ChangeLog:

	PR c++/25814
	* c.opt (Wvexing-parse): New option.

gcc/cp/ChangeLog:

	PR c++/25814
	* cp-tree.h (enum cp_tree_index): Add CPTI_EXPLICIT_VOID_LIST.
	(explicit_void_list_node): Define.
	(PARENTHESIZED_LIST_P): New macro.
	(struct cp_declarator): Add function::parens_loc.
	* decl.c (cxx_init_decl_processing): Initialize explicit_void_list_node.
	(grokparms): Also break when explicit_void_list_node.
	* parser.c (make_call_declarator): New location_t parameter.  Use it
	to set declarator->u.function.parens_loc.
	(cp_parser_lambda_declarator_opt): Pass UNKNOWN_LOCATION to
	make_call_declarator.
	(warn_about_ambiguous_parse): New function.
	(cp_parser_init_declarator): Call warn_about_ambiguous_parse.
	(cp_parser_declarator): Set *parenthesized_p to false rather than to
	true.
	(cp_parser_direct_declarator): Create a location for the function's
	parentheses and pass it to make_call_declarator.
	(cp_parser_parameter_declaration_clause): Return explicit_void_list_node
	for (void).
	(cp_parser_parameter_declaration_list): Set PARENTHESIZED_LIST_P
	in the parameters tree.

gcc/ChangeLog:

	PR c++/25814
	* doc/invoke.texi: Document -Wvexing-parse.

gcc/testsuite/ChangeLog:

	PR c++/25814
	* g++.dg/cpp2a/fn-template16.C: Add a dg-warning.
	* g++.dg/cpp2a/fn-template7.C: Likewise.
	* g++.dg/lookup/pr80891-5.C: Likewise.
	* g++.dg/lto/pr79050_0.C: Add extern.
	* g++.dg/lto/pr84805_0.C: Likewise.
	* g++.dg/parse/pr58898.C: Add a dg-warning.
	* g++.dg/template/scope5.C: Likewise.
	* g++.old-deja/g++.brendan/recurse.C: Likewise.
	* g++.old-deja/g++.jason/template4.C: Likewise.
	* g++.old-deja/g++.law/arm4.C: Likewise.
	* g++.old-deja/g++.mike/for2.C: Likewise.
	* g++.old-deja/g++.other/local4.C: Likewise.
	* g++.old-deja/g++.pt/crash3.C: Likewise.
	* g++.dg/warn/Wvexing-parse.C: New test.
	* g++.dg/warn/Wvexing-parse2.C: New test.
	* g++.dg/warn/Wvexing-parse3.C: New test.
	* g++.dg/warn/Wvexing-parse4.C: New test.
	* g++.dg/warn/Wvexing-parse5.C: New test.
	* g++.dg/warn/Wvexing-parse6.C: New test.
	* g++.dg/warn/Wvexing-parse7.C: New test.

libstdc++-v3/ChangeLog:

	PR c++/25814
	* testsuite/20_util/reference_wrapper/lwg2993.cc: Add a dg-warning.
	* testsuite/25_algorithms/generate_n/87982_neg.cc: Likewise.
2020-11-05 15:55:14 -05:00
Jonathan Wakely
d16d45655d libstdc++: Fix typo in ChangeLog entry 2020-11-05 19:35:34 +00:00
Jonathan Wakely
cdd2d448d8 libstdc++: Fix constraints on std::optional comparisons [PR 96269]
The relational operators for std::optional were using the wrong types
in the declval expressions used to constrain them. Instead of using
const lvalues they were using non-const rvalues, which meant that a type
might satisfy the constraints but then give an error when the function
body was instantiated.

libstdc++-v3/ChangeLog:

	PR libstdc++/96269
	* include/std/optional (operator==, operator!=, operator<)
	(operator>, operator<=, operator>=): Fix types used in
	SFINAE constraints.
	* testsuite/20_util/optional/relops/96269.cc: New test.
2020-11-05 19:09:22 +00:00
Jonathan Wakely
2f93a2a03a libstdc++: Use non-throwing increment in recursive_directory_iterator [PR 97731]
As described in the PR, the recursive_directory_iterator constructor
calls advance(ec), but ec is a pointer so it calls _Dir::advance(bool).
The intention was to either call advance() or advance(*ec) depending
whether the pointer is null or not.

This fixes the bug and renames the parameter to ecptr to make similar
mistakes less likely in future.

libstdc++-v3/ChangeLog:

	PR libstdc++/97731
	* src/filesystem/dir.cc (recursive_directory_iterator): Call the
	right overload of _Dir::advance.
	* testsuite/experimental/filesystem/iterators/97731.cc: New test.
2020-11-05 18:01:26 +00:00
Jonathan Wakely
710508c7b1 libstdc++: Fix multiple definitions of std::exception_ptr functions [PR 97729]
This fixes some multiple definition errors caused by the changes for
PR libstdc++/90295. The previous solution for inlining the members of
std::exception_ptr but still exporting them from the library was to
suppress the 'inline' keyword on those functions when compiling
libsupc++/eh_ptr.cc, so they get defined in that file. That produces ODR
violations though, because there are now both inline and non-inline
definitions in the library, due to the use of std::exception_ptr in
other files sucg as src/c++11/future.cc.

The new solution is to define all the relevant members as 'inline'
unconditionally, but use __attribute__((used)) to cause definitions to
be emitted in libsupc++/eh_ptr.cc as before. This doesn't quite work
however, because PR c++/67453 means the attribute is ignored on
constructors and destructors. As a workaround, the old solution
(conditionally inline) is still used for those members, but they are
given the always_inline attribute so that they aren't emitted in
src/c++11/future.o as inline definitions.

libstdc++-v3/ChangeLog:

	PR libstdc++/97729
	* include/std/future (__basic_future::_M_get_result): Use
	nullptr for null pointer constant.
	* libsupc++/eh_ptr.cc (operator==, operator!=): Remove
	definitions.
	* libsupc++/exception_ptr.h (_GLIBCXX_EH_PTR_USED): Define
	macro to conditionally add __attribute__((__used__)).
	(operator==, operator!=, exception_ptr::exception_ptr())
	(exception_ptr::exception_ptr(const exception_ptr&))
	(exception_ptr::~exception_ptr())
	(exception_ptr::operator=(const exception_ptr&))
	(exception_ptr::swap(exception_ptr&)): Always define as
	inline. Add macro to be conditionally "used".
2020-11-05 18:01:25 +00:00
Jonathan Wakely
50b840ac5e libstdc++: Export basic_stringbuf constructor [PR 97729]
libstdc++-v3/ChangeLog:

	PR libstdc++/97729
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Add exports.
	* src/c++20/sstream-inst.cc (basic_stringbuf): Instantiate
	private constructor taking __xfer_bufptrs.
2020-11-05 18:01:25 +00:00
Jonathan Wakely
432258be4f libstdc++: Fix new <sstream> constructors
- Add a missing 'explicit' to a basic_stringbuf constructor.
- Set up the get/put area pointers in the constructor from strings using
  different allocator types.
- Remove public basic_stringbuf::__sv_type alias.
- Do not construct temporary basic_string objects with a
  default-constructed allocator.

Also, change which basic_string constructor is used, as a minor
compile-time optimization. Constructing from a basic_string_view
requires more work from the compiler, so just use a pointer and length.

libstdc++-v3/ChangeLog:

	* include/std/sstream (basic_stringbuf(const allocator_type&):
	Add explicit.
	(basic_stringbuf(const basic_string<C,T,SA>&, openmode, const A&)):
	Call _M_stringbuf_init. Construct _M_string from pointer and length
	to avoid constraint checks for string view.
	(basic_stringbuf::view()): Make __sv_type alias local to the
	function.
	(basic_istringstream(const basic_string<C,T,SA>&, openmode, const A&)):
	Pass string to _M_streambuf instead of constructing a temporary
	with the wrong allocator.
	(basic_ostringstream(const basic_string<C,T,SA>&, openmode, const A&)):
	Likewise.
	(basic_stringstream(const basic_string<C,T,SA>&, openmode, const A&)):
	Likewise.
	* src/c++20/sstream-inst.cc: Use string_view and wstring_view
	typedefs in explicit instantiations.
	* testsuite/27_io/basic_istringstream/cons/char/1.cc: Add more
	tests for constructors.
	* testsuite/27_io/basic_ostringstream/cons/char/1.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/cons/char/1.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/cons/char/2.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/cons/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_stringstream/cons/char/1.cc: Likewise.
2020-11-05 13:31:32 +00:00
Jonathan Wakely
cbc3f0bcc0 libstdc++: Adjust whitespace in <sstream>
libstdc++-v3/ChangeLog:

	* include/std/sstream: Adjust whitespace.
2020-11-05 13:31:32 +00:00
GCC Administrator
35c125cb6a Daily bump. 2020-11-05 00:16:36 +00:00
Jonathan Wakely
8f565d255a libstdc++: Fix default mode of new basic_stringstream constructor [PR 97719]
libstdc++-v3/ChangeLog:

	PR libstdc++/97719
	* include/std/sstream (basic_stringstream(string_type&&, openmode)):
	Fix default argument.
	* testsuite/27_io/basic_stringstream/cons/char/97719.cc: New test.
2020-11-04 23:41:02 +00:00
Jonathan Wakely
9c1125c121 libstdc++: Fix test failure with --disable-linux-futex
As noted in PR 96817 this new test fails if the library is built without
futexes. That's expected of course, but we might as well fail more
obviously than a deadlock that eventually times out.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/96817.cc: Fail fail if the library is
	configured to not use futexes.
2020-11-04 15:30:54 +00:00
Jonathan Wakely
e0af865ab9 libstdc++: Define new C++17 std::search overload for Parallel Mode [PR 94971]
libstdc++-v3/ChangeLog:

	PR libstdc++/94971
	* include/bits/stl_algo.h (search(FIter, FIter, const Searcher):
	Adjust #if condition.
	* include/parallel/algo.h (search(FIter, FIter, const Searcher&):
	Define new overload for C++17.
2020-11-04 13:36:32 +00:00
Jonathan Wakely
3ef33e756a libstdc++: Document istreambuf_iterator base class change [PR 92285]
libstdc++-v3/ChangeLog:

	PR libstdc++/92285
	* doc/xml/manual/evolution.xml: Document change to base class.
	* doc/html/manual/api.html: Regenerate.
2020-11-04 12:46:52 +00:00
Jonathan Wakely
24366207b7 libstdc++: Fix constant expressions in std::uniform_int_distribution
Clang and EDG say the class member access expressions __urng.min() and
__urng.max() are not constant expressions, because the object expression
__urng is not usable in a constant expresion. Use a qualified-id to call
those static member functions instead.

Co-authored-by: Stephan Bergmann <sbergman@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (uniform_int_distribution::_S_nd):
	Use qualified-id to refer to static member functions.
2020-11-04 10:36:45 +00:00
GCC Administrator
fd2325ea60 Daily bump. 2020-11-04 00:16:41 +00:00
Jonathan Wakely
e1276e3342 libstdc++: Ensure std::lock_guard is declared
libstdc++-v3/ChangeLog:

	* include/std/syncstream: Include <bits/std_mutex.h>
	unconditionally.
2020-11-03 21:56:44 +00:00
François Dumont
12d0512305 libstdc++: Add mising gnu-versioned-namespace symbols
libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu-versioned-namespace.ver:
	Add __istream_extract and _Safe_local_iterator_base::_M_attach_single
	symbols.
2020-11-03 22:01:55 +01:00
Jonathan Wakely
9f925f3b19 libstdc++: Refactor std::call_once internals
This separates the definition of std::__call_proxy into two funcions,
one for TLS and one for non-TLS, to make them easier to read. It also
replaces the __get_once_functor_lock_ptr() internal helper with a new
set_lock_ptr(unique_lock<mutex>*) function so that __once_proxy doesn't
need to call it twice.

libstdc++-v3/ChangeLog:

	* src/c++11/mutex.cc [_GLIBCXX_HAVE_TLS] (__once_proxy): Define
	separately for TLS targets.
	[!_GLIBCXX_HAVE_TLS] (__get_once_functor_lock_ptr): Replace with ...
	(set_lock_ptr): ... this. Set new value and return previous
	value.
	[!_GLIBCXX_HAVE_TLS] (__set_once_functor_lock_ptr): Adjust to
	use set_lock_ptr.
	[!_GLIBCXX_HAVE_TLS] (__once_proxy): Likewise.
2020-11-03 20:03:16 +00:00
Jonathan Wakely
93e79ed391 libstdc++: Rewrite std::call_once to use futexes [PR 66146]
The current implementation of std::call_once uses pthread_once, which
only meets the C++ requirements when compiled with support for
exceptions. For most glibc targets and all non-glibc targets,
pthread_once does not work correctly if the init_routine exits via an
exception. The pthread_once_t object is left in the "active" state, and
any later attempts to run another init_routine will block forever.

This change makes std::call_once work correctly for Linux targets, by
replacing the use of pthread_once with a futex, based on the code from
__cxa_guard_acquire. For both glibc and musl, the Linux implementation
of pthread_once is already based on futexes, and pthread_once_t is just
a typedef for int, so this change does not alter the layout of
std::once_flag. By choosing the values for the int appropriately, the
new code is even ABI compatible. Code that calls the old implementation
of std::call_once will use pthread_once to manipulate the int, while new
code will use the new std::once_flag members to manipulate it, but they
should interoperate correctly. In both cases, the int is initially zero,
has the lowest bit set when there is an active execution, and equals 2
after a successful returning execution. The difference with the new code
is that exceptional exceptions are correctly detected and the int is
reset to zero.

The __cxa_guard_acquire code (and musl's pthread_once) use an additional
state to say there are other threads waiting. This allows the futex wake
syscall to be skipped if there is no contention. Glibc doesn't use a
waiter bit, so we have to unconditionally issue the wake in order to be
compatible with code calling the old std::call_once that uses Glibc's
pthread_once. If we know that we're using musl (and musl's pthread_once
doesn't change) it would be possible to set a waiting state and check
for it in std::once_flag::_M_finish(bool), but this patch doesn't do
that.

This doesn't fix the bug for non-linux targets. A similar approach could
be used for targets where we know the definition of pthread_once_t is a
mutex and an integer. We could make once_flag._M_activate() use
pthread_mutex_lock on the mutex member within the pthread_once_t, and
then only set the integer if the execution finishes, and then unlock the
mutex. That would require careful study of each target's pthread_once
implementation and that work is left for a later date.

This also fixes PR 55394 because pthread_once is no longer needed, and
PR 84323 because the fast path is now just an atomic load.

As a consequence of the new implementation that doesn't use
pthread_once, we can also make std::call_once work for targets with no
gthreads support. The code for the single-threaded implementation
follows the same methods as on Linux, but with no need for atomics or
futexes.

libstdc++-v3/ChangeLog:

	PR libstdc++/55394
	PR libstdc++/66146
	PR libstdc++/84323
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Add new symbols.
	* include/std/mutex [!_GLIBCXX_HAS_GTHREADS] (once_flag): Define
	even when gthreads is not supported.
	(once_flag::_M_once) [_GLIBCXX_HAVE_LINUX_FUTEX]: Change type
	from __gthread_once_t to int.
	(once_flag::_M_passive(), once_flag::_M_activate())
	(once_flag::_M_finish(bool), once_flag::_Active_execution):
	Define new members for futex and non-threaded implementation.
	[_GLIBCXX_HAS_GTHREADS] (once_flag::_Prepare_execution): New
	RAII helper type.
	(call_once): Use new members of once_flag.
	* src/c++11/mutex.cc (std::once_flag::_M_activate): Define.
	(std::once_flag::_M_finish): Define.
	* testsuite/30_threads/call_once/39909.cc: Do not require
	gthreads.
	* testsuite/30_threads/call_once/49668.cc: Likewise.
	* testsuite/30_threads/call_once/60497.cc: Likewise.
	* testsuite/30_threads/call_once/call_once1.cc: Likewise.
	* testsuite/30_threads/call_once/dr2442.cc: Likewise.
	* testsuite/30_threads/call_once/once_flag.cc: Add test for
	constexpr constructor.
	* testsuite/30_threads/call_once/66146.cc: New test.
	* testsuite/30_threads/call_once/constexpr.cc: Removed.
	* testsuite/30_threads/once_flag/cons/constexpr.cc: Removed.
2020-11-03 18:44:49 +00:00
Jonathan Yong
08fca4df1d libstdc++: use lt_host_flags for libstdc++.la
For platforms like Mingw and Cygwin, cygwin refuses to generate the
shared library without using -no-undefined.

Attached patch makes sure the right flags are used, since libtool is
already used to link libstdc++.

libstdc++-v3/ChangeLog:

	* src/Makefile.am (libstdc___la_LINK): Add lt_host_flags.
	* src/Makefile.in: Regenerate.
2020-11-03 08:22:53 +00:00
GCC Administrator
88ce3d5fbb Daily bump. 2020-11-02 20:53:00 +00:00
Thomas Rodgers
6bcbcea058 libstdc++: Add c++2a <syncstream>
libstdc++-v3/ChangeLog:
	* doc/doxygen/user.cfg.in (INPUT): Add new header.
	* include/Makefile.am (std_headers): Add new header.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Include new header.
	* include/std/syncstream: New header.
	* include/std/version: Add __cpp_lib_syncbuf.
	* testsuite/27_io/basic_syncbuf/1.cc: New test.
	* testsuite/27_io/basic_syncbuf/2.cc: Likewise.
	* testsuite/27_io/basic_syncbuf/basic_ops/1.cc:
	Likewise.
	* testsuite/27_io/basic_syncbuf/requirements/types.cc:
	Likewise.
	* testsuite/27_io/basic_syncbuf/sync_ops/1.cc:
	Likewise.
	* testsuite/27_io/basic_syncstream/1.cc: Likewise.
	* testsuite/27_io/basic_syncstream/2.cc: Likewise.
	* testsuite/27_io/basic_syncstream/basic_ops/1.cc:
	Likewise.
	* testsuite/27_io/basic_syncstream/requirements/types.cc:
	Likewise.
2020-11-02 10:41:32 -08:00
Jonathan Wakely
29e4184858 libstdc++: Define type traits for wchar_t even when libc support missing
This meets the requirement that std::is_integral_v<wchar_t> is true,
even when full library support for wchar_t via specializations of
char_traits etc. is not provided. This is done by checking
__WCHAR_TYPE__ to see if the compiler knows about the type, rather than
checking the library's own _GLIBCXX_USE_WCHAR_T autoconf macro.

This assumes that the C++ compiler correctly defines wchar_t as a
distinct type, not a typedef for one of the other integeral types. This
is always true for G++ and should be true for any supported non-GNU
compilers.

Similarly, the std::make_unsigned and std::make_signed traits and the
internal helpers std::__is_integer and std::__is_char are also changed
to depend on the same macro.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_integral<wchar_t>)
	(make_unsigned<wchar_t>, make_signed<wchar_t>): Define based
	on #ifdef __WCHAR_TYPE__ instead of _GLIBCXX_USE_WCHAR_T.
	* include/bits/cpp_type_traits.h (__is_integer<wchar_t>)
	(__is_char<wchar_t>): Likewise.
2020-11-01 11:39:07 +00:00
François Dumont
de77abee11 libstdc++: Fix gnu-version-namespace buid
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog

	* src/c++17/floating_from_chars.cc (_GLIBCXX_USE_CX11_ABI): Add define.
	(buffering_string): New.
	[!_GLIBCXX_USE_CXX11_ABI](reserve_string): New.
	(from_chars): Adapt.
	* src/c++20/sstream-inst.cc: Limit instantiations to
	_GLIBCXX_USE_CXX11_ABI.
2020-10-31 18:10:10 +01:00
Jonathan Wakely
60d9f25487 libstdc++: Prefer double to long double in std::shuffle_order_engine
The transition algorithm for std::shuffle_order_engine uses long double
to ensure that the value (max() - min() + 1) can be accurately
represented, to avoid bias in the shuffling. However, when the base
engine's range is small enough we can avoid slower long double
arithmetic by using double. For example, long double is unnecessary for
any base engine returning 32-bit values.

This makes std::knuth_b::operator() about 15% faster on x86_64, and
probably even more on targets where long double uses soft-float.

libstdc++-v3/ChangeLog:

	* include/bits/random.h (independent_bit_engine): Fix typo
	in comment.
	(shuffle_order_engine): Fix incorrect description in comment.
	* include/bits/random.tcc (__representable_as_double
	(__p1_representable_as_double): New helper functions.
	(shuffle_order_engine::operator()): Use double for calculation
	if (max() - min() + 1) is representable as double.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.
2020-10-31 12:54:03 +00:00
Jonathan Wakely
943cc2a1b7 libstdc++: Use double for unordered container load factors [PR 96958]
My previous commit for this PR changed the types from long double to
double, but didn't change the uses of __builtin_ceill and
__builtin_floorl. It also failed to change the non-inline functions in
src/c++11/hashtable_c++0x.cc. This should fix it properly now.

libstdc++-v3/ChangeLog:

	PR libstdc++/96958
	* include/bits/hashtable_policy.h (_Prime_rehash_policy)
	(_Power2_rehash_policy): Use ceil and floor instead of ceill and
	floorl.
	* src/c++11/hashtable_c++0x.cc (_Prime_rehash_policy): Likewise.
	Use double instead of long double.
2020-10-31 00:52:57 +00:00
Patrick Palka
afb8da7faa libstdc++: Don't initialize from *this inside some views [PR97600]
This works around a subtle issue where instantiating the begin()/end()
member of some views (as part of return type deduction) inadvertently
requires computing the satisfaction value of range<foo_view>.

This is problematic because the constraint range<foo_view> requires the
begin()/end() member to be callable.  But it's not callable until we've
deduced its return type, so evaluation of range<foo_view> yields false
at this point.  And if after both members are instantiated (and their
return types deduced) we evaluate range<foo_view> again, this time it
will yield true since the begin()/end() members are now both callable.
This makes the program ill-formed according to [temp.constr.atomic]/3:

  If, at different points in the program, the satisfaction result is
  different for identical atomic constraints and template arguments, the
  program is ill-formed, no diagnostic required.

The views affected by this issue are those whose begin()/end() member
has a placeholder return type and that member initializes an _Iterator
or _Sentinel object from a reference to *this.  The second condition is
relevant because it means explicit conversion functions are considered
during overload resolution (as per [over.match.copy], I think), and
therefore it causes g++ to check the constraints of the conversion
function view_interface<foo_view>::operator bool().  And this conversion
function's constraints indirectly require range<foo_view>.

This issue is observable on trunk only with basic_istream_view (as in
the testcase in the PR).  But a pending patch that makes g++ memoize
constraint satisfaction values indefinitely (it currently invalidates
the satisfaction cache on various events) causes many existing tests for
the other affected views to fail, because range<foo_view> then remains
false for the whole compilation.

This patch works around this issue by adjusting the constructors of the
_Iterator and _Sentinel types of the affected views to take their
foo_view argument by pointer instead of by reference, so that g++ no
longer considers explicit conversion functions when resolving the
direct-initialization inside these views' begin()/end() members.

libstdc++-v3/ChangeLog:

	PR libstdc++/97600
	* include/std/ranges (basic_istream_view::begin): Initialize
	_Iterator from 'this' instead of '*this'.
	(basic_istream_view::_Iterator::_Iterator): Adjust constructor
	accordingly.
	(filter_view::_Iterator::_Iterator): Take a filter_view*
	argument instead of a filter_view& argument.
	(filter_view::_Sentinel::_Sentinel): Likewise.
	(filter_view::begin): Initialize _Iterator from 'this' instead
	of '*this'.
	(filter_view::end): Likewise.
	(transform_view::_Iterator::_Iterator): Take a _Parent* instead
	of a _Parent&.
	(filter_view::_Iterator::operator+): Adjust accordingly.
	(filter_view::_Iterator::operator-): Likewise.
	(filter_view::begin): Initialize _Iterator from 'this' instead
	of '*this'.
	(filter_view::end): Likewise.
	(join_view::_Iterator): Take a _Parent* instead of a _Parent&.
	(join_view::_Sentinel): Likewise.
	(join_view::begin): Initialize _Iterator from 'this' instead of
	'*this'.
	(join_view::end): Initialize _Sentinel from 'this' instead of
	'*this'.
	(split_view::_OuterIter): Take a _Parent& instead of a _Parent*.
	(split_view::begin): Initialize _OuterIter from 'this' instead
	of '*this'.
	(split_view::end): Likewise.
	* testsuite/std/ranges/97600.cc: New test.
2020-10-30 20:33:19 -04:00
Jonathan Wakely
39bf4f14fc libstdc++: Implement P2017R1 "Conditionally borrowed ranges"
This makes some range adaptors model the borrowed_range concept if they
are adapting a borrowed range. This hasn't been added to the C++23
working paper yet, but it has been approved by LWG, and the
recommendation is to treat it as a defect report for C++20 as well.

libstdc++-v3/ChangeLog:

	* include/std/ranges (enable_borrowed_view<take_view<T>>)
	(enable_borrowed_view<drop_view<T>>)
	(enable_borrowed_view<drop_while_view<T>>)
	(enable_borrowed_view<reverse_view<T>>)
	(enable_borrowed_view<common_view<T>>)
	(enable_borrowed_view<elements_view<T>>): Add partial
	specializations as per P2017R1.
	* testsuite/std/ranges/adaptors/conditionally_borrowed.cc:
	New test.
2020-10-30 23:25:52 +00:00
Jonathan Wakely
a1343e5c74 libstdc++: Use double for unordered container load factors [PR 96958]
These calculations were changed to use long double nearly ten years ago
in order to get more precision than float:
https://gcc.gnu.org/pipermail/libstdc++/2011-September/036420.html

However, double should be sufficient, whlie being potentially faster
than long double, and not requiring soft FP calculations for targets
without native long double support.

libstdc++-v3/ChangeLog:

	PR libstdc++/96958
	* include/bits/hashtable_policy.h (_Prime_rehash_policy)
	(_Power2_rehash_policy): Use double instead of long double.
2020-10-30 20:58:08 +00:00
Jonathan Wakely
d1e5d82af8 libstdc++: Fix some more warnings in test
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc:
	Avoid -Wcatch-value warnings.
2020-10-30 20:58:08 +00:00
Patrick Palka
f3ced6772e libstdc++: Fix the default constructor of ranges::__detail::__box
The class template semiregular-box<T> of [range.semi.wrap] is specified
to value-initialize the underlying object whenever its type is default
initializable.  Our primary template for __detail::__box respects this
requirement, but the recently added partial specialization (for types
that are already semiregular) does not.

This patch fixes this issue, and additionally makes the corresponding in
place constructor explicit (as in the primary template).

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__box): For the partial
	specialization used by types that are already semiregular,
	make the default constructor value-initialize the underlying
	object instead of default-initializing it.  Make its in place
	constructor explicit.
	* testsuite/std/ranges/adaptors/detail/semiregular_box.cc:
	Augment test.
2020-10-30 12:33:13 -04:00
David Edelsohn
dec1eb4c27 libstdc++: AIX xfail for_overwrite.cc testcase
The 20_util/unique_ptr/creation/for_overwrite.cc testcase relies on
operator new, which requires special features on AIX.  This patch
disables the testcase.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/unique_ptr/creation/for_overwrite.cc: XFAIL on AIX.
2020-10-29 21:57:24 -04:00
GCC Administrator
4f0606fe4b Daily bump. 2020-10-30 00:16:29 +00:00
Jonathan Wakely
ffe6b41015 libstdc++: Fix linker script to remove conflicting patterns
This should fix a bootstrap error on Solaris, due to some of the new
symbols matching old patterns as well as new ones.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Tighten patterns
	for old <sstream> symbols some more.
2020-10-29 22:47:22 +00:00
Jonathan Wakely
a55cda891d libstdc++: Avoid narrowing conversion in subrange constructor
libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange::subrange(R&&)): Use
	direct-initialization instead of list-initialization, so a
	potential narrowing conversion from ranges::size(r) to the
	stored size isn't ill-formed.
2020-10-29 22:47:22 +00:00
Jonathan Wakely
d7aa21a3c7 libstdc++: Fix some warnings in headers
These are usually suppressed in system headers, but should be fixed
anyway.

libstdc++-v3/ChangeLog:

	* include/bits/parse_numbers.h (_Select_int_base): Avoid
	narrowing conversion in constant expression.
	* include/experimental/buffer (buffer_copy): Avoid narrowing
	conversion.
	* include/experimental/internet (hash<>::operator()): Do not
	use deprecated 'argument_type' member.
	* include/std/variant (variant::emplace): Use cast instead
	of implicit conversion from size_t to narrower unsigned type.
2020-10-29 22:47:22 +00:00
Jonathan Wakely
52ddf0d458 libstdc++: Prevent deprecation warnings from <tr1/shared_ptr>
libstdc++-v3/ChangeLog:

	* include/tr1/shared_ptr.h (__shared_count, __shared_ptr)
	(shared_ptr): Add diagnostic pragmas around uses of auto_ptr.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
	Adust dg-error line numbers.
2020-10-29 22:47:22 +00:00
Jonathan Wakely
13feb0234b libstdc++: Avoid warnings in tests
This fixes some warnings emitted when testing with warning flags added.
Some of these are only necessary when testing with -Wsystem-headers, but
either way it cleans up the tests to be less noisy under non-default
flags.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/96817.cc: Avoid -Wunused warnings.
	* testsuite/20_util/any/assign/2.cc: Likewise.
	* testsuite/20_util/any/cons/2.cc: Likewise.
	* testsuite/20_util/align/1.cc: Avoid -Wsign-compare warning.
	* testsuite/20_util/function/65760.cc: Avoid -Wunused warning.
	* testsuite/20_util/function/1.cc: Avoid -Wcatch-value warning.
	* testsuite/20_util/function/cons/move_target.cc: Avoid -Wunused
	warning.
	* testsuite/20_util/headers/memory/synopsis.cc: Add exception
	specification.
	* testsuite/20_util/monotonic_buffer_resource/allocate.cc: Avoid
	-Wsign-compare warning.
	* testsuite/20_util/tuple/cons/deduction.cc: Avoid -Wunused
	warning.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc:
	Avoid -Wdeprecated-copy warning.
	* testsuite/21_strings/basic_string/56166.cc: Avoid
	-Wcatch-value warning.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
	Avoid -Wcatch-value warnings.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc:
	Prune additional diagnostics.
	* testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc:
	Likewise.
	* testsuite/21_strings/headers/string/synopsis.cc: Add exception
	specifications.
	* testsuite/22_locale/locale/cons/12352.cc: Define sized
	delete operators to avoid warnings.
	* testsuite/23_containers/deque/modifiers/swap/1.cc: Add
	exception specification.
	* testsuite/23_containers/forward_list/cons/11.cc: Avoid
	-Wdeprecated-copy warning.
	* testsuite/23_containers/headers/bitset/synopsis.cc: Add
	exception specification.
	* testsuite/23_containers/headers/deque/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/forward_list/synopsis.cc:
	Likewise.
	* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/map/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/queue/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/set/synopsis.cc: Likewise.
	* testsuite/23_containers/headers/vector/synopsis.cc: Likewise.
	* testsuite/23_containers/list/modifiers/swap/1.cc: Likewise.
	* testsuite/23_containers/map/modifiers/swap/1.cc: Likewise.
	* testsuite/23_containers/multimap/modifiers/swap/1.cc:
	Likewise.
	* testsuite/23_containers/multiset/modifiers/swap/1.cc:
	Likewise.
	* testsuite/23_containers/set/modifiers/swap/1.cc: Likewise.
	* testsuite/23_containers/unordered_set/56267-2.cc: Avoid
	-Wdeprecated-copy warning.
	* testsuite/23_containers/vector/bool/23632.cc: Avoid
	-Wempty-body warning.
	* testsuite/23_containers/vector/modifiers/swap/1.cc: Add
	exception specification.
	* testsuite/25_algorithms/heap/moveable2.cc: Fix misplaced
	parentheses around arguments.
	* testsuite/25_algorithms/sample/1.cc: Use return value.
	* testsuite/25_algorithms/search/searcher.cc: Avoid -Wunused
	warnings.
	* testsuite/27_io/basic_ostream/exceptions/char/9561.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Avoid
	-Wsign-compare warning.
	* testsuite/experimental/any/assign/2.cc: Avoid -Wunused warnings.
	* testsuite/experimental/any/cons/2.cc: Likewise.
	* testsuite/experimental/filesystem/operations/remove_all.cc:
	Avoid -Wign-compare warning.
	* testsuite/experimental/memory/observer_ptr/cons/cons.cc:
	Likewise.
	* testsuite/experimental/memory_resource/null_memory_resource.cc:
	Likewise.
	* testsuite/experimental/source_location/1.cc: Avoid -Waddress
	warning.
	* testsuite/ext/pod_char_traits.cc: Avoid -Wunused warning.
	* testsuite/ext/vstring/modifiers/clear/56166.cc: Avoid
	-Wcatch-value.
	* testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc:
	Avoid -Wunused warning.
	* testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
	Prune additional warnings.
	* testsuite/tr1/3_function_objects/function/1.cc: Avoid
	-Wcatch-value warning.
	* testsuite/util/replacement_memory_operators.h: Define sized
	delete to avoid warnings.
	* testsuite/util/testsuite_api.h (_NonDefaultConstructible): Add
	user-declared assignment operator to stop -Wdeprecated-copy
	warnings.
	* testsuite/util/testsuite_containers.h: Avoid -Wunused warning.
	* testsuite/util/testsuite_iterators.h: Avoid -Wsign-compare
	warnings.
	* testsuite/util/testsuite_new_operators.h: Define sized deleted.
2020-10-29 22:47:21 +00:00
Jonathan Wakely
8c84486bba libstdc++: Improve tests for constexpr algorithms
These tests just return true without checking that the results of the
algorithms. Although it should be safe to assume that the algorithms
behave the same at compile-time as at run-time, we can use these tests
to verify it.

This replaces each 'return true' statement with a condition that depends
on the basic functionality of the algorithm, such as returning an
iterator to the right position.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/all_of/constexpr.cc: Check result of
	the algorithm.
	* testsuite/25_algorithms/any_of/constexpr.cc: Likewise.
	* testsuite/25_algorithms/binary_search/constexpr.cc: Likewise.
	* testsuite/25_algorithms/copy_backward/constexpr.cc: Likewise.
	* testsuite/25_algorithms/count/constexpr.cc: Likewise.
	* testsuite/25_algorithms/equal/constexpr.cc: Likewise.
	* testsuite/25_algorithms/equal_range/constexpr.cc: Likewise.
	* testsuite/25_algorithms/fill/constexpr.cc: Likewise.
	* testsuite/25_algorithms/find_end/constexpr.cc: Likewise.
	* testsuite/25_algorithms/find_if/constexpr.cc: Likewise.
	* testsuite/25_algorithms/is_partitioned/constexpr.cc: Likewise.
	* testsuite/25_algorithms/is_permutation/constexpr.cc: Likewise.
	* testsuite/25_algorithms/is_sorted_until/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/lexicographical_compare/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/lower_bound/constexpr.cc: Likewise.
	* testsuite/25_algorithms/merge/constexpr.cc: Likewise.
	* testsuite/25_algorithms/mismatch/constexpr.cc: Likewise.
	* testsuite/25_algorithms/none_of/constexpr.cc: Likewise.
	* testsuite/25_algorithms/partition_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/remove_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/remove_copy_if/constexpr.cc: Likewise.
	* testsuite/25_algorithms/remove_if/constexpr.cc: Likewise.
	* testsuite/25_algorithms/replace_if/constexpr.cc: Likewise.
	* testsuite/25_algorithms/reverse/constexpr.cc: Likewise.
	* testsuite/25_algorithms/reverse_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/rotate_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/search/constexpr.cc: Likewise.
	* testsuite/25_algorithms/set_difference/constexpr.cc: Likewise.
	* testsuite/25_algorithms/set_intersection/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/set_union/constexpr.cc: Likewise.
	* testsuite/25_algorithms/unique_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/constexpr.cc: Likewise.
2020-10-29 14:47:18 +00:00
Jonathan Wakely
822c1d21a3 libstdc++: Allow Lemire's algorithm to be used in more cases
This extends the fast path to also work when the URBG's range of
possible values is not the entire range of its result_type. Previously,
the slow path would be used for engines with a uint_fast32_t result type
if that type is actually a typedef for uint64_t rather than uint32_t.
After this change, the generator's result_type is not important, only
the range of possible value that generator can produce. If the
generator's range is exactly UINT64_MAX then the calculation will be
done using 128-bit and 64-bit integers, and if the range is UINT32_MAX
it will be done using 64-bit and 32-bit integers.

In practice, this benefits most of the engines and engine adaptors
defined in [rand.predef] on x86_64-linux and other 64-bit targets. This
is because std::minstd_rand0 and std::mt19937 and others use
uint_fast32_t, which is a typedef for uint64_t.

The code now makes use of the recently-clarified requirement that the
generator's min() and max() functions are usable in constant
expressions (see LWG 2154).

libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (_Power_of_two): Add
	constexpr.
	(uniform_int_distribution::_S_nd): Add static_assert to ensure
	the wider type is twice as wide as the result type.
	(uniform_int_distribution::__generate_impl): Add static_assert
	and declare variables as constexpr where appropriate.
	(uniform_int_distribution:operator()): Likewise. Only consider
	the uniform random bit generator's range of possible results
	when deciding whether _S_nd can be used, not the __uctype type.
2020-10-29 14:47:18 +00:00
Jonathan Wakely
d067bd7293 libstdc++: Do not use volatile for __gnu_cxx::rope reference counting
The rope extension uses a volatile variable for its reference count.
This is not only unnecessary for correctness (volatile provides neither
atomicity nor memory visibility, and the variable is only modified while
a lock is held) but it now causes deprecated warnings with
-Wsystem-headers due to the use of ++ and -- operators.

It would be possible to use __gnu_cxx::__exchange_and_add in _M_incr and
_M_decr when __atomic_is_lock_free(sizeof(_RC_t), &_M_ref_count) is
true, rather than locking a mutex. That would probably be a significant
improvement for multi-threaded and single-threaded code (because
__exchange_and_add will use non-atomic ops when possible, and even in MT
code it should be faster than the mutex lock/unlock pair). However,
mixing objects compiled with the old and new code would result in
inconsistent synchronization being used for the reference count.

libstdc++-v3/ChangeLog:

	* include/ext/rope (_Refcount_Base::_M_ref_count): Remove
	volatile qualifier.
	(_Refcount_Base::_M_decr()): Likewise.
2020-10-29 14:47:17 +00:00
Jonathan Wakely
3c9b99ef71 libstdc++: Make std::function work better with -fno-rtti
This change allows std::function::target<F>() to work even without RTTI,
using the same approach as std::any. Because we know what the manager
function would be for a given type, we can check if the stored pointer
has the expected address. If it does, we don't need to use RTTI. If it
isn't equal, we still need to do the RTTI check (when RTTI is enabled)
to handle the case where the same function has different addresses in
different shared objects.

This also changes the implementation of the manager function to return a
null pointer result when asked for the type_info of the target object.
This not only avoids a warning with -Wswitch -Wsystem-headers, but also
avoids prevents std::function::target_type() from dereferencing an
uninitialized pointer when the linker keeps an instantiation of the
manager function that was compiled without RTTI.

Finally, this fixes a bug in the non-const overload of function::target
where calling it with a function type F was ill-formed, due to
attempting to use const_cast<F*>(ptr). The standard only allows
const_cast<T*> when T is an object type.  The solution is to use
*const_cast<F**>(&ptr) instead, because F* is an object type even if F
isn't. I've also used _GLIBCXX17_CONSTEXPR in function::target so that
it doesn't bother instantiating anything for types that can never be a
valid target.

libstdc++-v3/ChangeLog:

	* include/bits/std_function.h (_Function_handler<void, void>):
	Define explicit specialization used for invalid target types.
	(_Base_manager::_M_manager) [!__cpp_rtti]: Return null.
	(function::target_type()): Check for null pointer.
	(function::target()): Define unconditionall. Fix bug with
	const_cast of function pointer type.
	(function::target() const): Define unconditionally, but
	only use RTTI if enabled.
	* testsuite/20_util/function/target_no_rtti.cc: New test.
2020-10-29 14:47:17 +00:00
Patrick Palka
2e0216f9c4 libstdc++: Fix memory issue in ranges::lexicographical_compare testcase
libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/lexicographical_compare/constrained.cc:
	(test03): Fix initializing the vector vy with the array y of size 4.
2020-10-29 10:11:12 -04:00
Patrick Palka
64817472be libstdc++: Correct PR number in ChangeLog entry 2020-10-29 09:28:43 -04:00
Jonathan Wakely
eb6b71b83c libstdc++: Fix some warnings in headers
These are usually suppressed without -Wsystem-headers.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h (_Local_iterator_base): Cast
	value to avoid -Wsign-compare warnings.
	* include/bits/regex.h (sub_match::_M_str): Avoid narrowing
	conversion.
	* include/bits/regex_compiler.tcc (_Compiler::_M_quantifier):
	Initialize variable to avoid -Wmaybe-uninitialized warning.
	* include/bits/shared_ptr_base.h (_Sp_counted_deleter::_Impl):
	Reorder mem-initializer-list to avoid -Wreorder warning.
	* include/bits/stl_tree.h (_Rb_tree_impl): Explicitly
	initialize base class in copy constructor.
	* include/debug/safe_iterator.h (_Safe_iterator): Likewise.
	* include/ext/debug_allocator.h: Reorder mem-initializer-list
	to avoid -Wreorder warning.
	* include/ext/throw_allocator.h (throw_allocator_limit)
	(throw_allocator_random): Add user-declared assignment operators
	to avoid -Wdeprecated-copy warnings.
2020-10-29 11:43:55 +00:00
Jonathan Wakely
68990ed13d libstdc++: Rename _UniformRandomNumberGenerator parameters
The paper P0346R1 renamed uniform random number generators to
uniform random bit generators, to describe their purpose more
accurately. This makes that same change in one of the relevant
files (but not the others).

libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (uniform_int_distribution):
	Rename _UniformRandomNumberGenerator template parameters to
	_UniformRandomBitGenerator, as per P0346R1.
2020-10-29 09:09:44 +00:00
Jonathan Wakely
c6bfc4eb3c libstdc++: Fix new basic_stringbuf constructor
libstdc++-v3/ChangeLog:

	* include/std/sstream (basic_stringbuf(__string_type&&, openmode)):
	Call _M_init_syncbuf to set up get/put areas. Also qualify
	std::move.
2020-10-29 01:28:12 +00:00
GCC Administrator
e93aae4a49 Daily bump. 2020-10-29 00:16:50 +00:00
Jonathan Wakely
f4f9364d20 libstdc++: Fix linker script
libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Remove duplicate
	patterns.
	(CXXABI_1.3.13): Restore missing piece.
2020-10-28 23:52:12 +00:00
Thomas Rodgers
a0e4d7b44c libstdc++: Implement C++20 features for <sstream>
New ctors and ::view() accessor for -
  * basic_stingbuf
  * basic_istringstream
  * basic_ostringstream
  * basic_stringstreamm

New ::get_allocator() accessor for basic_stringbuf.

libstdc++-v3/ChangeLog:
	* acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): New symbols.
	* configure: Regenerate.
	* include/std/sstream:
	(basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
	(basic_stringbuf::basic_stringbuf(openmode, allocator const&)): Likewise.
	(basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
	(basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&)):
	Likewise.
	(basic_stringbuf::get_allocator()): New method.
	(basic_stringbuf::view()): Likewise.
	(basic_istringstream::basic_istringstream(basic_string&&, openmode)):
	New constructor.
	(basic_istringstream::basic_istringstream(openmode, allocator const&)):
	Likewise
	(basic_istringstream::view()): New method.
	(basic_ostringstream::basic_ostringstream(basic_string&&, openmode)):
	New constructor.
	(basic_ostringstream::basic_ostringstream(openmode, allocator const&)):
	Likewise
	(basic_ostringstream::view()): New method.
	(basic_stringstream::basic_stringstream(basic_string&&, openmode)):
	New constructor.
	(basic_stringstream::basic_stringstream(openmode, allocator const&)):
	Likewise
	(basic_stringstream::view()): New method.
	* src/Makefile.in: Add c++20 directory.
	* src/Makefile.am: Regenerate.
	* src/c++20/Makefile.am: Add makefile for new sub-directory.
	* src/c++20/Makefile.in: Generate.
	* src/c++20/sstream-inst.cc: New file defining explicit
	instantiations for basic_stringbuf, basic_istringstream,
	basic_ostringstream, and basic_stringstream member functions
	added in C++20.
	* testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test.
	* testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/view/char/1.cc: Likewise.
	* testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_istringstream/cons/char/1.cc: Likewise.
	* testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_istringstream/view/char/1.cc: Likewise.
	* testsuite/27_io/basic_istringstream/view/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostringstream/cons/char/1.cc: Likewise.
	* testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_ostringstream/view/char/1.cc: Likewise.
	* testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_stringstream/cons/char/1.cc: Likewise.
	* testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc: Likewise.
	* testsuite/27_io/basic_stringstream/view/char/1.cc: Likewise.
	* testsuite/27_io/basic_stringstream/view/wchar_t/1.cc: Likewise.
2020-10-28 11:56:06 -07:00
Patrick Palka
8572edc828 libstdc++: Fix arithmetic bug in year_month_weekday conversion [PR96713]
The conversion function year_month_weekday::operator sys_days computes
the offset in days from the first weekday of the month with:

 days{(index()-1)*7}
      ^~~~~~~~~~~~~  type 'unsigned'

We want the above to yield -7d when index() is 0u, but our 'days' alias
is based on long instead of int, so the conversion from unsigned to the
underlying type of 'days' instead yields a large positive value.

This patch fixes this by casting the result of index() to int so that
the initializer is sign-extended in the conversion to long.

The added testcase also verifies we do the right thing when index() == 5.

libstdc++-v3/ChangeLog:

	PR libstdc++/96713
	* include/std/chrono (year_month_weekday::operator sys_days):
	Cast the result of index() to int so that the initializer for
	days{} is sign-extended when it's converted to the underlying
	type.
	* testsuite/std/time/year_month_weekday/3.cc: New test.
2020-10-28 12:28:08 -04:00
Jonathan Wakely
c227d96feb libstdc++: Add comment to nothrow new explaining catch (...)
The decision to not rethrow a __forced_unwind exception is deliberate,
so add a comment explaining it.

libstdc++-v3/ChangeLog:

	* libsupc++/new_opnt.cc (new): Add comment about forced unwind
	exceptions.
2020-10-28 13:19:21 +00:00
Jonathan Wakely
0bc199fc5d libstdc++: Override BUFSIZ for Windows targets [PR 94268]
This replaces uses of BUFSIZ with a new _GLIBCXX_BUFSIZ macro that can
be overridden in target-specific config headers.

That allows the mingw and mingw-w64 targets to override it, because
BUFSIZ is apparently defined to 512, resulting in poor performance. The
MSVCRT stdio apparently uses 4096, so we use that too.

libstdc++-v3/ChangeLog:

	PR libstdc++/94268
	* config/os/mingw32-w64/os_defines.h (_GLIBCXX_BUFSIZ):
	Define.
	* config/os/mingw32/os_defines.h (_GLIBCXX_BUFSIZ):
	Define.
	* include/bits/fstream.tcc: Use _GLIBCXX_BUFSIZ instead
	of BUFSIZ.
	* include/ext/stdio_filebuf.h: Likewise.
	* include/std/fstream (_GLIBCXX_BUFSIZ): Define.
2020-10-28 13:19:21 +00:00
Jonathan Wakely
72a87d82e0 libstdc++: Fix name clash with _Cosh in QNX headers [PR 95592]
This replaces unqualified names like _Cosh with struct std::_Cosh to
ensure there is no ambiguity with other entities with the same name.

libstdc++-v3/ChangeLog:

	PR libstdc++/95592
	* include/bits/valarray_after.h (_DEFINE_EXPR_UNARY_OPERATOR)
	(_DEFINE_EXPR_BINARY_OPERATOR, _DEFINE_EXPR_BINARY_FUNCTION):
	Use elaborated-type-specifier and qualified-id to avoid
	ambiguities with QNX system headers.
	* testsuite/26_numerics/valarray/95592.cc: New test.
2020-10-28 12:35:44 +00:00
Jonathan Wakely
0f7cd5e573 libstdc++: Make std::span layout-compatible with struct iovec [PR 95609]
This change reorders the data members of std::span so that span<byte> is
layout-compatible with common implementations of struct iovec. This will
allow span<byte> to be used directly in places that use a struct iovec
to do scatter-gather I/O.

It's important to note that POSIX doesn't specify the order of members
in iovec. Also the equivalent type on Windows has members in the other
order, and uses type ULONG (which is always 32-bit whereas size_t is
64-bit for Win64). So this change will only help for certain targets and
an indirection between std::span and I/O system calls will still be
needed for the general case.

libstdc++-v3/ChangeLog:

	PR libstdc++/95609
	* include/std/span (span): Reorder data members to match common
	implementations of struct iovec.
	* testsuite/23_containers/span/layout_compat.cc: New test.
2020-10-28 12:07:40 +00:00
GCC Administrator
89bb01e7cb Daily bump. 2020-10-28 00:16:38 +00:00
Jonathan Wakely
d4fd8638be libstdc++: Fix ODR violations caused by <tr1/functional>
The placeholders for std::tr1::bind are defined in an anonymous
namespace, which means they have internal linkage. This will cause ODR
violations when used in function templates (such as std::tr1::bind) from
multiple translation units. Although probably harmless (every definition
will generate identical code, even if technically ill-formed) we can
avoid the ODR violations by reusing the std::placeholder objects as the
std::tr1::placeholder objects.

To make this work, the std::_Placeholder type needs to be defined for
C++98 mode, so that <tr1/functional> can use it. The members of the
std::placeholder namespace must not be defined by <functional> in C++98
mode, because "placeholders", "_1", "_2" etc. are not reserved names in
C++98. Instead they can be declared in <tr1/functional>, because those
names *are* reserved in that header. With the std::placeholders objects
declared, a simple using-directive suffices to redeclare them in
namespace std::tr1::placeholders. This means any use of the TR1
placeholders actually refers to the C++11 placeholders, which are
defined with external linkage and exported from the library, so don't
cause ODR violations.

libstdc++-v3/ChangeLog:

	* include/std/functional (std::_Placeholder): Define for C++98
	as well as later standards.
	* include/tr1/functional (std::placeholders::_1 etc): Declare
	for C++98.
	(tr1::_Placeholder): Replace with using-declaration for
	std::_Placeholder.
	(tr1::placeholders::_1 etc.): Replace with using-directive for
	std::placeholders.
2020-10-27 16:32:53 +00:00
Jonathan Wakely
86558afc09 libstdc++: Remove unused variables in special functions
libstdc++-v3/ChangeLog:

	* include/tr1/ell_integral.tcc (__ellint_rf, __ellint_rd)
	(__ellint_rc, __ellint_rj): Remove unused variables.
	* include/tr1/modified_bessel_func.tcc (__airy): Likewise.
2020-10-27 16:32:53 +00:00
Jonathan Wakely
2232b61368 libstdc++: Fix -Wsign-compare warnings in headers
libstdc++-v3/ChangeLog:

	* include/bits/locale_conv.h (__str_codecvt_out_all):
	Add cast to compare operands of the same signedness.
	* include/bits/locale_facets_nonio.tcc
	(time_get::_M_extract_wday_or_month): Likewise.
	* include/bits/sstream.tcc (basic_stringbuf::overflow):
	Likewise.
	* include/tr1/legendre_function.tcc (__sph_legendre): Use
	unsigned for loop variable.
2020-10-27 16:32:53 +00:00
Jonathan Wakely
e579f66c3c libstdc++: Add missing noexcept to std::from_chars declarations
libstdc++-v3/ChangeLog:

	* include/std/charconv (from_chars): Add noexcept to match
	definitions in src/c++17/floating_from_chars.cc
2020-10-27 14:50:38 +00:00
Jonathan Wakely
044b04348c libstdc++: Fix directory_iterator exception specification
libstdc++-v3/ChangeLog:

	* src/c++17/fs_dir.cc (fs::directory_iterator::operator*):
	Add noexcept. Do not throw on precondition violation.
2020-10-27 14:50:37 +00:00
Jonathan Wakely
fe9d058ca2 libstdc++: Add noexcept to declaration of path::_List members
libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (path::_List::begin, path::_List::end):
	Add noexcept to match definitions in src/c++17/fs_path.cc.
2020-10-27 14:50:37 +00:00
Jonathan Wakely
01079b6a92 libstdc++: Include <cstdint> in tests that use std::uintptr_t
libstdc++-v3/ChangeLog:

	* testsuite/experimental/memory_resource/new_delete_resource.cc:
	Add missing <cstdint> header.
	* testsuite/experimental/memory_resource/resource_adaptor.cc:
	Likewise.
2020-10-27 13:48:54 +00:00
GCC Administrator
f19e7c8d5b Daily bump. 2020-10-27 00:16:28 +00:00
Jonathan Wakely
b784bbbe45 libstdc++: Fix error in experimental::strand
libstdc++-v3/ChangeLog:

	* include/experimental/executor (strand::_State): Fix thinko.
2020-10-26 21:00:06 +00:00
Ville Voutilainen
9e2256dcd4 c++: Implement __is_nothrow_constructible and __is_nothrow_assignable
gcc/c-family/ChangeLog:

	* c-common.c (__is_nothrow_assignable): New.
	(__is_nothrow_constructible): Likewise.
	* c-common.h (RID_IS_NOTHROW_ASSIGNABLE): New.
	(RID_IS_NOTHROW_CONSTRUCTIBLE): Likewise.

gcc/cp/ChangeLog:

	* cp-tree.h (CPTK_IS_NOTHROW_ASSIGNABLE): New.
	(CPTK_IS_NOTHROW_CONSTRUCTIBLE): Likewise.
	(is_nothrow_xible): Likewise.
	* method.c (is_nothrow_xible): New.
	(is_trivially_xible): Tweak.
	* parser.c (cp_parser_primary_expression): Handle the new RID_*.
	(cp_parser_trait_expr): Likewise.
	* semantics.c (trait_expr_value): Handle the new RID_*.
	(finish_trait_expr): Likewise.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (__is_nt_constructible_impl): Remove.
	(__is_nothrow_constructible_impl): Adjust.
	(is_nothrow_default_constructible): Likewise.
	(__is_nt_assignable_impl): Remove.
	(__is_nothrow_assignable_impl): Adjust.
2020-10-26 15:36:24 +02:00
Jonathan Wakely
93e9a7bcd5 libstdc++: Fix declarations of memalign etc. for freestanding [PR 97570]
libstdc++-v3/ChangeLog:

	PR libstdc++/97570
	* libsupc++/new_opa.cc: Declare size_t in global namespace.
	Remove unused header.
2020-10-26 12:02:50 +00:00
Stephan Bergmann
dc7824734e libstdc++: Add missing exception-specifications in shared_ptr
libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_base.h
	(_Sp_counted_base::_M_add_ref_lock_nothrow(): Add noexcept to
	definitions to match declaration.
	(__shared_count(const __weak_count&, nothrow_t)): Add noexcept
	to declaration to match definition.
2020-10-26 10:15:45 +00:00
GCC Administrator
efe71fcc4c Daily bump. 2020-10-24 00:16:29 +00:00
Patrick Palka
50106208ff libstdc++: Apply proposed resolutions for LWG 3428, 3447
libstdc++-v3/ChangeLog:

	* include/std/ranges (single_view::single_view): Mark the
	in place constructor explicit as per LWG 3428.
	(take_view): Remove the constraint on the deduction guide's
	template parameter as per LWG 3447.
2020-10-23 09:03:25 -04:00
GCC Administrator
43868df37b Daily bump. 2020-10-23 00:16:30 +00:00
Jonathan Wakely
ca021ac617 libstdc++: Ensure std::forward_as_tuple is defined
The recent changes to reduce includes in <memory_resource> went a bit
too far, and it's possible for std::forward_as_tuple to not be defined
when used.

While doing this, I noticed the problematic calls to forward_as_tuple
were not qualified, so performed unwanted ADL.

libstdc++-v3/ChangeLog:

	* include/experimental/memory_resource: Include <tuple>.
	(polymorphic_allocator::construct): Qualify forward_as_tuple.
	* include/std/memory_resource: Likewise.
2020-10-23 01:12:00 +01:00
Jonathan Wakely
0a74a0e1a2 libstdc++: Fix custom clock in test
This test fails in C++20 mode because std::is_clock is false for the
test clock, because it doesn't define a duration member.

libstdc++-v3/ChangeLog:

	* testsuite/30_threads/condition_variable/members/68519.cc:
	Define recent_epoch_float_clock::duration to meet the Cpp17Clock
	requirements.
2020-10-22 23:14:13 +01:00
Jonathan Wakely
f5d9bc8ae8 libstdc++: Only include <condition_variable> in <shared_mutex> if needed
The <condition_variable> header is not small, so <shared_mutex> should
not include it unless it actually needs std::condition_variable, which
is only the case when we don't have pthread_rwlock_t and the POSIX
Timers option.

The <shared_mutex> header would be even smaller if we had a header for
std::condition_variable (separate from std::condition_variable_any).
That's already planned for a future change.

And <memory_resource> would be even smaller if it was possible to get
std::shared_mutex without std::shared_timed_mutex (which depends on
<chrono>). For that to be effective, the synchronized_pool_resource
would have to create its own simpler version of std::shared_lock without
the timed waiting functions. I have no plans to do that.

libstdc++-v3/ChangeLog:

	* include/std/shared_mutex: Only include <condition_variable>
	when pthread_rwlock_t and POSIX timers are not available.
	(__cpp_lib_shared_mutex, __cpp_lib_shared_timed_mutex): Change
	value to be type 'long'.
	* include/std/version (__cpp_lib_shared_mutex)
	(__cpp_lib_shared_timed_mutex): Likewise.
2020-10-22 18:49:38 +01:00
Jonathan Wakely
b1e7c6fce1 libstdc++: Reduce header dependencies in and on <memory>
By moving std::make_obj_using_allocator and the related "utility
functions for uses-allocator construction" to a new header, we can avoid
including the whole of <memory> in <scoped_allocator> and
<memory_resource>.

In order to simplify the implementation of those utility functions they
now use concepts unconditionally. They are no longer defined if
__cpp_concepts is not defined. To simplify the code that uses those
functions I've introduced a __cpp_lib_make_obj_using_allocator feature
test macro (not specified in the standard, which might be an oversight).
That allows the code in <memory_resource> and <scoped_allocator> to
check the feature test macro to decide whether to use the new utilities,
or fall back to the C++17 code.

At the same time, this reshuffles some of the headers included by
<memory> so that they are (mostly?) self-contained. It should no longer
be necessary to include other headers before <bits/shared_ptr.h> when
other parts of the library want to use std::shared_ptr without including
the whole of <memory>.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/shared_ptr.h: Include <iosfwd>.
	* include/bits/shared_ptr_base.h: Include required headers here
	directly, instead of in <memory>.
	* include/bits/uses_allocator_args.h: New file. Move utility
	functions for uses-allocator construction from <memory> to here.
	Only define the utility functions when concepts are available.
	(__cpp_lib_make_obj_using_allocator): Define non-standard
	feature test macro.
	* include/std/condition_variable: Remove unused headers.
	* include/std/future: Likewise.
	* include/std/memory: Remove headers that are not needed
	directly, and are now inclkuded where they're needed. Include
	new <bits/uses_allocator_args.h> header.
	* include/std/memory_resource: Include only the necessary
	headers. Use new feature test macro to detect support for the
	utility functions.
	* include/std/scoped_allocator: Likewise.
	* include/std/version (__cpp_lib_make_obj_using_allocator):
	Define.
2020-10-22 18:42:03 +01:00
Olivier Hainque
d667beea36 Scope libstdc++ configuration for vxworks to all versions
When libstdc++ is enabled, the current high level configuration
bits should apply the same to all versions of VxWorks.  Adjust the
config triplets matching rules accordingly.

2010-10-21  Olivier Hainque  <hainque@adacore.com>

libstdc++-v3/
	* crossconfig.m4: Turn vxworks matcher into vxworks*.
	* configure.host: Likewise.
	* configure: Regenerate.
2020-10-22 16:40:57 +00:00
GCC Administrator
56ddd5e23a Daily bump. 2020-10-22 08:28:22 +00:00
Jonathan Wakely
945151b7f1 libstdc++: Simplify std::shared_ptr construction from std::weak_ptr
The _M_add_ref_lock() and _M_add_ref_lock_nothrow() members of
_Sp_counted_base are very similar, except that the former throws an
exception when the use count is zero and the latter returns false. The
former (and its callers) can be implemented in terms of the latter.
This results in a small reduction in code size, because throwing an
exception now only happens in one place.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr.h (shared_ptr(const weak_ptr&, nothrow_t)):
	Add noexcept.
	* include/bits/shared_ptr_base.h (_Sp_counted_base::_M_add_ref_lock):
	Remove specializations and just call _M_add_ref_lock_nothrow.
	(__shared_count, __shared_ptr): Use nullptr for null pointer
	constants.
	(__shared_count(const __weak_count&)): Use _M_add_ref_lock_nothrow
	instead of _M_add_ref_lock.
	(__shared_count(const __weak_count&, nothrow_t)): Add noexcept.
	(__shared_ptr::operator bool()): Add noexcept.
	(__shared_ptr(const __weak_ptr&, nothrow_t)): Add noexcept.
2020-10-21 21:13:41 +01:00
Jonathan Wakely
a186ab670e libstdc++: Make structured bindings always work for subranges [PR 97512]
The definition of ranges::subrange was moved to the new
<bits/ranges_util.h> header so that it could be used in <algorithm>
without including the whole of <ranges>. However, the tuple-like support
that enables subrange to be used with structured bindings was left in
<ranges>. This is arguably conforming (to use a subrange you should
include <ranges>) but it's inconvenient and probably confusing.

This change makes the tuple-like support available whenever subrange
itself is available.

libstdc++-v3/ChangeLog:

	PR libstdc++/97512
	* include/bits/ranges_util.h (tuple_size<subrange>)
	(tuple_element<I, cv subrange>): Move here from ...
	* include/std/ranges: ... here.
	* testsuite/std/ranges/subrange/97512.cc: New test.
2020-10-21 14:40:54 +01:00
Thomas Rodgers
e957b86ca2 libstdc++: Rebase include/pstl to current upstream
From llvm-project/pstl @ 0b2e0e80d96

libstdc++-v3/ChangeLog:

	* include/pstl/algorithm_impl.h: Update file.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/glue_memory_impl.h: Likewise.
	* include/pstl/glue_numeric_impl.h: Likewise.
	* include/pstl/memory_impl.h: Likewise.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/parallel_backend_serial.h: Likewise.
	* include/pstl/parallel_backend_tbb.h: Likewise.
	* include/pstl/parallel_backend_utils.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
2020-10-21 06:11:28 -07:00
GCC Administrator
e2e0428854 Daily bump. 2020-10-21 00:16:36 +00:00
François Dumont
1b6f047683 libstdc++: Refactor _Hashtable to prepare for custom pointers
Limit usage of node pointers in _Hashtable implementation details so that when
we move to allocator custom pointer type we do not need to add an _Alloc
template parameter everywhere which would impact abi.

This is done by reviewing node type definition. It is now based on new basic
types which are not pointer dependant. The _Hashtable helper
types are now using those new node base types and do not receive node pointers.

libstdc++-v3/ChangeLog

	* include/bits/hashtable_policy.h
	(_Hash_node_value_base<>): Remove _Hash_node_base inheritance.
	(_Hash_node_code_cache<bool _Cache_hash_code>): New.
	(_Hash_node_value<typename _Value, bool _Cache_hash_code>): New.
	(_Hash_node<>): Inherits _Hash_node_base<> and _Hash_node_value<>.
	(_Map_base<>::__node_type): Remove.
	(_Map_base<>::iterator): Remove.
	(_Insert_base<>::__hash_cached): New.
	(_Insert_base<>::__constant_iterators): New.
	(_Insert_base<>::__hashtable_alloc): New.
	(_Insert_base<>::__node_type): Remove.
	(_Insert_base<>::__node_ptr): New.
	(_Hash_code_base<>): Remove specializations.
	(_Hash_code_base<>::__node_type): Remove.
	(_Hash_code_base<>::_M_bucket_index(const __node_type*, size_t)):
	Replace by...
	(_Hash_code_base<>::_M_bucket_index(const _Hash_node_value<>&, size_t)):
	...this.
	(_Hash_code_base<>::_M_store_code(__node_type*, __hash_code)):
	Replace by...
	(_Hash_code_base<>::_M_store_code(_Hash_node_code_cache<>&, __hash_code)):
	...this.
	(_Hash_code_base<>::_M_copy_code(__node_type*, const __node_type*)):
	Replace by...
	(_Hash_code_base<>::_M_copy_code(_Hash_node_code_cache<>&,
	const _Hash_node_code_base<>&)): ...this.
	(_Hashtable_base<>::__constant_iterators): Remove.
	(_Hashtable_base<>::__unique_keys): Remove.
	(_Hashtable_base<>::__node_type): Remove.
	(_Hashtable_base<>::iterator): Remove.
	(_Hashtable_base<>::const_iterator): Remove.
	(_Hashtable_base<>::local_iterator): Remove.
	(_Hashtable_base<>::const_local_iterator): Remove.
	(_Hashtable_base<>::__ireturn_type): Remove.
	(_Hashtable_base<>::_Equal_hash_code<>::_S_equals): Replace by...
	(_Hashtable_base<>::_S_equals(__hash_code, const _Hash_node_code_hash<>&)):
	...this.
	(_Hashtable_base<>::_Equal_hash_code<>::_S_node_equals): Replace by...
	(_Hashtable_base<>::_S_node_equals(__hash_code,
	const _Hash_node_code_hash<>&)): ...this.
	(_Hashtable_base<>::_Equal_hash_code<>): Remove.
	(_Hashtable_base<>::_M_equals): Adapt.
	(_Hashtable_baxe<>::_M_node_equals): Adapt.
	(_Equality<>::_M_equal): Adapt.
	(_Hashtable_alloc<>::__node_ptr): New.
	(_Hashtable_alloc<>::__bucket_type): Rename into...
	(_Hashtable_alloc<>::__node_base_ptr): ...this.
	(_Hashtable_alloc<>::__bucket_alloc_type): Rename into...
	(_Hashtable_alloc<>::__buckets_alloc_type): ...this.
	(_Hashtable_alloc<>::__bucket_alloc_traits): Rename into...
	(_Hashtable_alloc<>::__buckets_alloc_traits): ...this.
	(_Hashtable_alloc<>::__buckets_ptr): New.
	(_Hashtable_alloc<>::_M_allocate_node): Adapt.
	(_Hashtable_alloc<>::_M_deallocate_node): Adapt.
	(_Hashtable_alloc<>::_M_deallocate_node_ptr): Adapt.
	(_Hashtable_alloc<>::_M_deallocate_nodes): Adapt.
	(_Hashtable_alloc<>::_M_allocate_buckets): Adapt.
	(_Hashtable_alloc<>::_M_deallocate_buckets): Adapt.
	* include/bits/hashtable.h (_Hashtable<>): Adapt.
2020-10-20 21:30:22 +02:00
Aldy Hernandez
e864d395b4 Convert -Wrestrict pass to ranger.
There is one adjustment to a C++ test which now gives a false positive.
After talking with Martin Sebor, we've concluded this is expected.  There
is no way to communicate that libstdc++ allocated objects are always
less than PTRDIFF_MAX.

gcc/ChangeLog:

	* calls.c (get_size_range): Adjust to work with ranger.
	* calls.h (get_size_range): Add ranger argument to prototype.
	* gimple-ssa-warn-restrict.c (class wrestrict_dom_walker): Remove.
	(check_call): Pull out of wrestrict_dom_walker into a
	static function.
	(wrestrict_dom_walker::before_dom_children): Rename to...
	(wrestrict_walk): ...this.
	(pass_wrestrict::execute): Instantiate ranger.
	(class builtin_memref): Add stmt and query fields.
	(builtin_access::builtin_access): Add range_query field.
	(builtin_memref::builtin_memref): Same.
	(builtin_memref::extend_offset_range): Same.
	(builtin_access::builtin_access): Make work with ranger.
	(wrestrict_dom_walker::check_call): Pull out into...
	(check_call): ...here.
	(check_bounds_or_overlap): Add range_query argument.
	* gimple-ssa-warn-restrict.h (check_bounds_or_overlap):
	Add range_query and gimple stmt arguments.

gcc/testsuite/ChangeLog:

	* gcc.dg/Wrestrict-22.c: New test.
	* g++.dg/torture/pr92421.C: Adjust for ranger.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/capacity/1.cc: Pass
	-Wno-stringop-overflow to test.
2020-10-20 20:46:08 +02:00
Jonathan Wakely
94fd05f1f7 libstdc++: Define noop coroutine details private and inline [PR 95917]
This moves the __noop_coro_frame type, the __noop_coro_fr global
variable, and the __dummy_resume_destroy function from namespace scope,
replacing them with private members of the specialization
coroutine_handle<noop_coroutine_promise>.

The function and variable are also declared inline, so that they
generate no code unless used.

libstdc++-v3/ChangeLog:

	PR libstdc++/95917
	* include/std/coroutine (__noop_coro_frame): Replace with
	noop_coroutine_handle::__frame.
	(__dummy_resume_destroy): Define inline in __frame.
	(__noop_coro_fr): Replace with noop_coroutine_handle::_S_fr
	and define as inline.
	* testsuite/18_support/coroutines/95917.cc: New test.
2020-10-20 11:37:48 +01:00
Jonathan Wakely
2c2278f300 libstdc++: Remove inheritance from std::coroutine_handle<> [LWG 3460]
This removes the coroutine_handle<> base class from the primary template
and the noop_coroutine_promise explicit specialization. To preserve the
API various members are added, as they are no longer inherited from the
base class.

I've also tweaked some indentation and formatting, and replaced
subclause numbers from the standard with stable names like
[coroutine.handle.con].

libstdc++-v3/ChangeLog:

	* include/std/coroutine (coroutine_handle<_Promise>): Remove
	base class. Add constructors, conversions, accessors etc. as
	proposed for LWG 3460.
	(coroutine_handle<noop_coroutine_promise>): Likewise.
	* testsuite/18_support/coroutines/lwg3460.cc: New test.
2020-10-20 11:37:48 +01:00
GCC Administrator
970d683f67 Daily bump. 2020-10-20 00:16:29 +00:00
Jonathan Wakely
e7a0af84d6 libstdc++: Implement std::make_unique_for_overwrite
This is the std::unique_ptr part of P1020R1 (as amended by P1973R1) for
C++20. The std::shared_ptr part still needs to be done.

libstdc++-v3/ChangeLog:

	* include/bits/unique_ptr.h (make_unique_for_overwrite): Define
	for C++20.
	* testsuite/20_util/unique_ptr/creation/array_neg.cc: Remove
	unused header. Adjust standard reference.
	* testsuite/20_util/unique_ptr/creation/for_overwrite.cc: New test.
	* testsuite/20_util/unique_ptr/creation/for_overwrite__neg.cc: New test.
2020-10-19 22:11:39 +01:00
Jonathan Wakely
fc77484c4a libstdc++: Use reserved name for C++20 attribute
Although the compiler supports the [[no_unique_address]] attribute, it's
not a reserved name prior to C++20, so we can't use it in std::tuple.
Use [[__no_unique_address__]] instead.

libstdc++-v3/ChangeLog:

	* include/std/tuple (_Head_base<Idx, Head, true>): Use reserved
	form of __no_unique_address__ attribute because
	no_unique_address is not reserved prior to C++20.
2020-10-19 18:07:21 +01:00
Jonathan Wakely
aa6d2be1e3 libstdc++: Optimize container node-handle type for size
The use of std::optional in _Node_handle makes the node handle types for
associative and unordered containers larger than necessary. It also
greatly increases the amount of code included, as <optional> is quite
large.

The boolean flag that records whether the std::optional contains a value
is redundant, because the _Node_handle::_M_ptr member provides the same
information. If the node handle has a non-null pointer it also has an
allocator, and not otherwise. By replacing std::optional with a custom
union type (and using _M_ptr to tell which union member is active) all
node handle sizes can be reduced by sizeof(allocator_type::pointer).

This makes the node handle types incompatible with previous releases, so
must be done before the C++17 ABI is fixed for GCC 11.

libstdc++-v3/ChangeLog:

	* include/bits/node_handle.h (_Node_handle_common): Replace
	std::optional with custom type.
	* testsuite/20_util/variant/exception_safety.cc: Add missing
	header include.
2020-10-19 18:06:51 +01:00
Jonathan Wakely
4ba60194bb libstdc++: Remove unused header
This header was not part of the patch submitted and reviewed, and was
not added to include/Makefile.am so never gets installed anyway. It
appears to have been committed by mistake, so let's remove it.

libstdc++-v3/ChangeLog:

	* include/precompiled/expc++.h: Removed.
2020-10-19 11:19:28 +01:00
GCC Administrator
019e1c85fe Daily bump. 2020-10-18 00:16:23 +00:00
Ville Voutilainen
1f65bf2aa6 libstdc++: Fix visitor return type diagnostics [PR97449]
libstdc++-v3/ChangeLog:

	PR libstdc++/97449
	* include/std/variant
	(__gen_vtable_impl<>::_S_apply_single_alt):
	Diagnose visitor return type mismatches here..
	(__gen_vtable_impl</*base case*/>::_S_apply):
	..not here.
2020-10-17 23:10:40 +03:00
GCC Administrator
b85d5dc583 Daily bump. 2020-10-16 00:16:29 +00:00
Jonathan Wakely
7dbf96e2a2 libstdc++: Fix typos in copyright notice
It looks like I did a s/a/__a/ substition in one of these headers, and
then copied it to the other one.

libstdc++-v3/ChangeLog:

	* include/std/concepts: Fix typos in copyright notice.
	* include/std/ranges: Likewise.
2020-10-15 19:20:21 +01:00
GCC Administrator
b2698c21f2 Daily bump. 2020-10-15 00:16:34 +00:00
Jonathan Wakely
78198b6021 libstdc++: Fix unspecified comparison to null pointer [PR 97415]
The standard doesn't guarantee that null pointers compare less than
non-null pointers. AddressSanitizer complains about the pptr()> egptr()
comparison in basic_stringbuf::str() when egptr() is null.

libstdc++-v3/ChangeLog:

	PR libstdc++/97415
	* include/std/sstream (basic_stringbuf::str()): Check for
	null egptr() before comparing to non-null pptr().
2020-10-14 18:55:14 +01:00
Jonathan Wakely
2b9c09a78b libstdc++: Fix tests that fail with old std::string ABI
These two tests have started to fail with the old std::string ABI. The
scan-assembler-not checks fail because they match debug info, not code.

Adding -g0 to the test flags fixes them.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/modifiers/assign/char/move_assign_optim.cc:
	Do not generate debug info.
	* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/move_assign_optim.cc:
	Likewise.
2020-10-14 16:15:49 +01:00
Jonathan Wakely
252c9967ba libstdc++: Define some std::string constructors inline
There are a lot of very simple constructors for the old string which are
not defined inline. I don't see any reason for this and it probably
makes them less likely to be optimized away. Move the definitions into
the class body.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (basic_string(const Alloc&))
	(basic_string(const basic_string&)
	(basic_string(const CharT*, size_type, const Alloc&))
	(basic_string(const CharT*, const Alloc&))
	(basic_string(size_type, CharT, const Alloc&))
	(basic_string(initializer_list<CharT>, const Alloc&))
	(basic_string(InputIterator, InputIterator, const Alloc&)):
	Define inline in class body.
	* include/bits/basic_string.tcc (basic_string(const Alloc&))
	(basic_string(const basic_string&)
	(basic_string(const CharT*, size_type, const Alloc&))
	(basic_string(const CharT*, const Alloc&))
	(basic_string(size_type, CharT, const Alloc&))
	(basic_string(initializer_list<CharT>, const Alloc&))
	(basic_string(InputIterator, InputIterator, const Alloc&)):
	Move definitions into class body.
2020-10-14 12:52:47 +01:00
Jonathan Wakely
a1b6b01361 libstdc++: Improve comments for check_effective_target_cxx11-abi
libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (check_effective_target_cxx11-abi):
	Add comments about which test flags get used by the check.
2020-10-14 12:52:47 +01:00
Jonathan Wakely
5e961dba46 libstdc++: Improve comments in std::string tests
The COW std::string does support some features of C++11 allocators, just
not propagation. Change some comments in the tests to be more precise
about that.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/allocator/char/copy.cc: Make
	comment more precise about what isn't supported by COW strings.
	* testsuite/21_strings/basic_string/allocator/char/copy_assign.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/char/move.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/char/move_assign.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/char/noexcept.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/char/operator_plus.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/char/swap.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/wchar_t/copy.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/wchar_t/move.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/wchar_t/noexcept.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/wchar_t/operator_plus.cc:
	Likewise.
	* testsuite/21_strings/basic_string/allocator/wchar_t/swap.cc:
	Likewise.
2020-10-14 12:52:47 +01:00
Jonathan Wakely
5ae9ddd480 libstdc++: Enable tests that incorrectly require cxx11-abi
These tests were not being run when -D_GLIBCXX_USE_CXX11_ABI=0 was added
to the test flags, but they actually work OK with the old string.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/allocator/char/minimal.cc:
	Do not require cxx11-abi effective target.
	* testsuite/21_strings/basic_string/allocator/wchar_t/minimal.cc:
	Likewise.
	* testsuite/27_io/basic_fstream/cons/base.cc: Likewise.
2020-10-14 12:52:46 +01:00
Jonathan Wakely
dc38e25524 libstdc++: Implement LWG 3706 for COW strings
The basic_string deduction guides are defined for the old ABI, but the
tests are currently disabled. This is because a single case fails when
using the old ABI, which is just because LWG 3706 isn't implemented for
the old ABI. That can be done easily, and the tests can be enabled.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
	(basic_string(const _CharT*, const _Alloc&)): Constrain to
	require an allocator-like type to fix CTAD ambiguity (LWG 3706).
	* testsuite/21_strings/basic_string/cons/char/deduction.cc:
	Remove dg-skip-if.
	* testsuite/21_strings/basic_string/cons/wchar_t/deduction.cc:
	Likewise.
2020-10-14 12:51:40 +01:00
GCC Administrator
bdd74cc20c Daily bump. 2020-10-14 00:16:24 +00:00
Nuno Lopes
5204cc561a libstdc++: Fix doxygen comment for std::any_of
libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h (any_of): Fix incorrect description
	in comment.
2020-10-13 20:21:55 +01:00
Jonathan Wakely
0e0beddd7f libstdc++: Update C++20 status documentation
libstdc++-v3/ChangeLog:

	* doc/xml/manual/evolution.xml: Document some API changes
	and deprecations.
	* doc/xml/manual/intro.xml: Document LWG 2499.
	* doc/xml/manual/status_cxx2020.xml: Update status.
	* doc/html/*: Regenerate.
2020-10-13 17:40:43 +01:00
Jonathan Wakely
16d0b033ca libstdc++: Remove trailing whitespace from XML docs
libstdc++-v3/ChangeLog:

	* doc/xml/book.txml: Remove trailing whitespace.
	* doc/xml/chapter.txml: Likewise.
	* doc/xml/class.txml: Likewise.
	* doc/xml/gnu/fdl-1.3.xml: Likewise.
	* doc/xml/gnu/gpl-3.0.xml: Likewise.
	* doc/xml/manual/abi.xml: Likewise.
	* doc/xml/manual/algorithms.xml: Likewise.
	* doc/xml/manual/allocator.xml: Likewise.
	* doc/xml/manual/appendix_contributing.xml: Likewise.
	* doc/xml/manual/appendix_free.xml: Likewise.
	* doc/xml/manual/appendix_porting.xml: Likewise.
	* doc/xml/manual/atomics.xml: Likewise.
	* doc/xml/manual/auto_ptr.xml: Likewise.
	* doc/xml/manual/backwards_compatibility.xml: Likewise.
	* doc/xml/manual/bitmap_allocator.xml: Likewise.
	* doc/xml/manual/build_hacking.xml: Likewise.
	* doc/xml/manual/codecvt.xml: Likewise.
	* doc/xml/manual/concurrency.xml: Likewise.
	* doc/xml/manual/concurrency_extensions.xml: Likewise.
	* doc/xml/manual/configure.xml: Likewise.
	* doc/xml/manual/containers.xml: Likewise.
	* doc/xml/manual/ctype.xml: Likewise.
	* doc/xml/manual/debug.xml: Likewise.
	* doc/xml/manual/debug_mode.xml: Likewise.
	* doc/xml/manual/diagnostics.xml: Likewise.
	* doc/xml/manual/documentation_hacking.xml: Likewise.
	* doc/xml/manual/evolution.xml: Likewise.
	* doc/xml/manual/internals.xml: Likewise.
	* doc/xml/manual/intro.xml: Likewise.
	* doc/xml/manual/io.xml: Likewise.
	* doc/xml/manual/iterators.xml: Likewise.
	* doc/xml/manual/locale.xml: Likewise.
	* doc/xml/manual/localization.xml: Likewise.
	* doc/xml/manual/messages.xml: Likewise.
	* doc/xml/manual/mt_allocator.xml: Likewise.
	* doc/xml/manual/numerics.xml: Likewise.
	* doc/xml/manual/parallel_mode.xml: Likewise.
	* doc/xml/manual/policy_data_structures.xml: Likewise.
	* doc/xml/manual/prerequisites.xml: Likewise.
	* doc/xml/manual/shared_ptr.xml: Likewise.
	* doc/xml/manual/spine.xml: Likewise.
	* doc/xml/manual/status_cxxtr1.xml: Likewise.
	* doc/xml/manual/status_cxxtr24733.xml: Likewise.
	* doc/xml/manual/strings.xml: Likewise.
	* doc/xml/manual/support.xml: Likewise.
	* doc/xml/manual/test.xml: Likewise.
	* doc/xml/manual/test_policy_data_structures.xml: Likewise.
	* doc/xml/manual/using.xml: Likewise.
	* doc/xml/manual/using_exceptions.xml: Likewise.
	* doc/xml/manual/utilities.xml: Likewise.
	* doc/html/*: Regenerate.
2020-10-13 16:50:41 +01:00
GCC Administrator
8be127cac9 Daily bump. 2020-10-13 00:16:26 +00:00
Patrick Palka
c5aad5a418 libstdc++: Apply proposed resolution for LWG 3450
libstdc++-v3/ChangeLog:

	* include/std/ranges (take_while_view::begin): Constrain the
	const overload further as per LWG 3450.
	(take_while_view::end): Likewise.
	* testsuite/std/ranges/adaptors/take_while.cc: Add test for LWG
	3450.
2020-10-12 13:46:24 -04:00
Patrick Palka
e066821b6f libstdc++: Apply proposed resolution for LWG 3449 [PR95322]
Now that the frontend bug PR96805 is fixed, we can cleanly apply the
proposed resolution for this issue.

This slightly deviates from the proposed resolution by declaring _CI a
member of take_view instead of take_view::_Sentinel, since it doesn't
depend on anything within _Sentinel anymore.

libstdc++-v3/ChangeLog:

	PR libstdc++/95322
	* include/std/ranges (take_view::_CI): Define this alias
	template as per LWG 3449 and remove ...
	(take_view::_Sentinel::_CI): ... this type alias.
	(take_view::_Sentinel::operator==): Adjust use of _CI
	accordingly.  Define a second overload that accepts an iterator
	of the opposite constness as per LWG 3449.
	(take_while_view::_Sentinel::operator==): Likewise.
	* testsuite/std/ranges/adaptors/95322.cc: Add tests for LWG 3449.
2020-10-12 13:46:21 -04:00
Jonathan Wakely
c840700852 libstdc++: Update doxyfile to Doxygen 1.8.20 format
libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in: Update to Doxygen 1.8.20 format.
2020-10-12 18:14:01 +01:00
Jonathan Wakely
925eb6a0fb libstdc++: Include C++17 features in doxygen API docs
libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (PREDEFINED): Use __cplusplus=201703L
	so that C++17 features are documented.
2020-10-12 18:14:01 +01:00
Jonathan Wakely
ae3967caff libstdc++: Fix documentation for return values of copy algos
The doxygen comments for these algos all incorrectly claim to use
(first - last) as the difference from the start of the output range to
the return value. As reported on the mailing list by Johannes Choo, it
should be (last - first).

libstdc++-v3/ChangeLog:

	* include/bits/stl_algobase.h (copy, move, copy_backward)
	(move_backward): Fix documentation for returned iterator.
2020-10-12 18:14:01 +01:00
Martin Sebor
1be51a3a9a PR c++/97201 - ICE in -Warray-bounds writing to result of operator new(0)
gcc/cp/ChangeLog:

	PR c++/97201
	* error.c (dump_type_suffix): Handle both the C and C++ forms of
	zero-length arrays.

libstdc++-v3/ChangeLog:

	PR c++/97201
	* libsupc++/new (operator new): Add attribute alloc_size and malloc.

gcc/testsuite/ChangeLog:

	PR c++/97201
	* g++.dg/warn/Wplacement-new-size-8.C: Adjust expected message.
	* g++.dg/warn/Warray-bounds-10.C: New test.
	* g++.dg/warn/Warray-bounds-11.C: New test.
	* g++.dg/warn/Warray-bounds-12.C: New test.
	* g++.dg/warn/Warray-bounds-13.C: New test.
2020-10-12 09:36:26 -06:00
GCC Administrator
2baa36d491 Daily bump. 2020-10-12 00:16:25 +00:00
Clément Chigot
0b9a731127 aix: add FAT library support for libstdc++fs.a
Make libstdc++fs.a a 32/64 bit FAT library.

It is too complicated for the FAT library Makefile fragment to determine if
--enable-libstdcxx-filesystem-ts has been enabled.  This patch checks the
existence of libstdc++fs.a at build time and adds the complementary object
file if it was built.

libstdc++-v3/Changelog:

2020-10-11  Clement Chigot  <clement.chigot@atos.net>

	* config/os/aix/t-aix: Add complementary mode object file to
	libstdc++fs.a
2020-10-11 11:47:00 -04:00
GCC Administrator
aab566a4fb Daily bump. 2020-10-11 00:16:25 +00:00
Jonathan Wakely
2137aa9241 libstdc++: Replace use of reserved name that clashes [PR 97362]
The name __deref is defined as a macro by Windows headers.

This renames the __deref() helper function to __ref. It doesn't actually
dereference an iterator. it just has the same type as the iterator's
reference type.

libstdc++-v3/ChangeLog:

	PR libstdc++/97362
	* doc/html/manual/source_code_style.html: Regenerate.
	* doc/xml/manual/appendix_contributing.xml: Add __deref to
	BADNAMES.
	* include/debug/functions.h (_Irreflexive_checker::__deref):
	Rename to __ref.
	* testsuite/17_intro/badnames.cc: Check __deref.
2020-10-10 21:22:12 +01:00
Ville Voutilainen
02cbd79e47 libstdc++: Fix variant build on 32-bit targets [PR95904]
libstdc++-v3/ChangeLog:

	* include/std/variant (__check_visitor_result):
	Use size_t for indexes.
	(__check_visitor_results): Likewise.
2020-10-10 14:03:00 +03:00
GCC Administrator
c74a0e82fa Daily bump. 2020-10-10 00:16:26 +00:00
Ville Voutilainen
3427e31331 libstdc++: Diagnose visitors with different return types [PR95904]
libstdc++-v3/ChangeLog:

	PR libstdc++/95904
	* include/std/variant (__deduce_visit_result): Add a nested ::type.
	(__gen_vtable_impl</*base case*/>::_S_apply):
	Check the visitor return type.
	(__same_types): New.
	(__check_visitor_result): Likewise.
	(__check_visitor_results): Likewise.
	(visit(_Visitor&&, _Variants&&...)): Use __check_visitor_results
	in case we're visiting just one variant.
	* testsuite/20_util/variant/visit_neg.cc: Adjust.
2020-10-09 20:48:08 +03:00
Jonathan Wakely
3ee44d4c51 libstdc++: Fix incorrect results in std::seed_seq::generate [PR 97311]
This ensures that intermediate results are done in uint32_t values,
meeting the requirement for operations to be done modulo 2^32.

If the target doesn't define __UINT32_TYPE__ then substitute uint32_t
with a class type that uses uint_least32_t and masks the value to
UINT32_MAX.

I've also split the first loop that goes from k=0 to k<m into three
loops, for k=0, [1,s] and [s+1,m). This avoids branching for those three
cases in the body of the loop, and also avoids the concerns in PR 94823
regarding the k-1 index when k==0.

libstdc++-v3/ChangeLog:

	PR libstdc++/97311
	* include/bits/random.tcc (seed_seq::generate): Use uint32_t for
	calculations. Also split the first loop into three loops to
	avoid branching on k on every iteration, resolving PR 94823.
	* testsuite/26_numerics/random/seed_seq/97311.cc: New test.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-erro
	line number.
2020-10-09 16:58:32 +01:00
Daniel Lemire
98c37d3bac libstdc++: Optimize uniform_int_distribution using Lemire's algorithm
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/uniform_int_dist.h (uniform_int_distribution::_S_nd):
	New member function implementing Lemire's "nearly divisionless"
	algorithm.
	(uniform_int_distribution::operator()): Use _S_nd when the range
	of the URBG is the full width of the result type.
2020-10-09 14:09:36 +01:00
Jonathan Wakely
6ce2cb116a libstdc++: Adjust variable export in makefile
We usually export variables in recipes this way. I'm not sure it's
necessary, but it's consistent.

libstdc++-v3/ChangeLog:

	* testsuite/Makefile.am: Set and export variable separately.
	* testsuite/Makefile.in: Regenerate.
2020-10-09 14:08:42 +01:00
Jonathan Wakely
7e7eef2a1b libstdc++: Pass CXXFLAGS to check_performance script
It looks like our check-performance target runs completely unoptimized,
which is a bit silly. This exports the CXXFLAGS from the parent make
process to the check_performance script.

libstdc++-v3/ChangeLog:

	* scripts/check_performance: Use gnu++11 instead of gnu++0x.
	* testsuite/Makefile.am (check-performance): Export CXXFLAGS to
	child process.
	* testsuite/Makefile.in: Regenerate.
2020-10-09 14:01:55 +01:00
Jonathan Wakely
f9919ba717 libstdc++: Add performance test for <random>
This tests std::uniform_int_distribution with various parameters and
engines.

libstdc++-v3/ChangeLog:

	* testsuite/performance/26_numerics/random_dist.cc: New test.
2020-10-09 14:01:54 +01:00
Jonathan Wakely
afcbeb35e0 libstdc++: Fix unused variable warning
libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_performance.h (report_header): Remove
	unused variable.
2020-10-09 11:53:08 +01:00
GCC Administrator
da9df69975 Daily bump. 2020-10-09 00:16:27 +00:00
Patrick Palka
9158a4d2a6 libstdc++: Make ranges::construct_at constexpr-friendly [PR95788]
This rewrites ranges::construct_at in terms of std::construct_at so
that we can piggyback on the compiler's existing support for
intercepting placement new within std::construct_at during constexpr
evaluation, instead of having to additionally teach the compiler about
ranges::construct_at.

While we're making changes to ranges::construct_at, this patch also
declares it conditionally noexcept and qualifies the calls to declval in
its requires-clause.

libstdc++-v3/ChangeLog:

	PR libstdc++/95788
	* include/bits/ranges_uninitialized.h:
	(__construct_at_fn::operator()): Rewrite in terms of
	std::construct_at.  Declare it conditionally noexcept.  Qualify
	calls to declval in its requires-clause.
	* testsuite/20_util/specialized_algorithms/construct_at/95788.cc:
	New test.
2020-10-08 18:10:05 -04:00
Jonathan Wakely
b2a96bf9dc libstdc++: Add assertions for preconditions in sampling distributions [PR 82584]
These three distributions all require 0 < S where S is the sum of the
weights. When the sum is zero there's an undefined FP division by zero.
Add assertions to help users diagnose the problem.

libstdc++-v3/ChangeLog:

	PR libstdc++/82584
	* include/bits/random.tcc
	(discrete_distribution::param_type::_M_initialize)
	(piecewise_constant_distribution::param_type::_M_initialize)
	(piecewise_linear_distribution::param_type::_M_initialize):
	Add assertions for positive sums..
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line.
2020-10-08 15:24:21 +01:00
Jonathan Wakely
f997b67550 libstdc++: Add C++11 member functions for ios::failure in old ABI
The new constructors that C++11 added to std::ios_base::failure were
missing for the old ABI. This adds them, but just ignores the
std::error_code argument (because there's nowhere to store it).

This also adds a code() member, which should be provided by the
std::system_error base class, but that base class isn't present in the
old ABI.

This allows the old ios::failure to be used in code that expects the new
API, although with reduced functionality.

libstdc++-v3/ChangeLog:

	* include/bits/ios_base.h (ios_base::failure): Add constructors
	takeing error_code argument. Add code() member function.
	* testsuite/27_io/ios_base/failure/cxx11.cc: Allow test to
	run for the old ABI but do not check for derivation from
	std::system_error.
	* testsuite/27_io/ios_base/failure/error_code.cc: New test.
2020-10-08 14:45:37 +01:00
Jonathan Wakely
c06617a79b libstdc++: Avoid divide by zero in default template arguments
My previous attempt to fix this only worked when m is a power of two.
There is still a bug when a=00 and !has_single_bit(m).

Instead of trying to make _Mod work for a==0 this change ensures that we
never instantiate it with a==0. For C++17 we can use if-constexpr, but
otherwise we need to use a different multipler. It doesn't matter what
we use, as it won't actually be called, only instantiated.

libstdc++-v3/ChangeLog:

	* include/bits/random.h (__detail::_Mod): Revert last change.
	(__detail::__mod): Do not use _Mod for a==0 case.
	* testsuite/26_numerics/random/linear_congruential_engine/operators/call.cc:
	Check other cases with a==0. Also check runtime results.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line.
2020-10-08 14:45:36 +01:00
GCC Administrator
6caec77e3b Daily bump. 2020-10-08 00:16:30 +00:00
Jonathan Wakely
6ae17a3b68 libstdc++: Fix divide by zero in default template argument
libstdc++-v3/ChangeLog:

	* include/bits/random.h (__detail::_Mod): Avoid divide by zero.
	* testsuite/26_numerics/random/linear_congruential_engine/operators/call.cc:
	New test.
2020-10-08 00:34:56 +01:00
Jonathan Wakely
23f75da95f libstdc++: Fix non-reserved names in headers
My recent changes to std::exception_ptr moved some members to be inline
in the header but didn't replace the variable names with reserved names.

The "tmp" variable must be fixed. The "other" parameter is actually a
reserved name because of std::allocator<T>::rebind<U>::other but should
be fixed anyway.

There are also some bad uses of "ForwardIterator" in <ranges>.

There's also a "il" parameter in a std::seed_seq constructor in <random>
which is only reserved since C++14.

libstdc++-v3/ChangeLog:

	* include/bits/random.h (seed_seq(initializer_list<T>)): Rename
	parameter to use reserved name.
	* include/bits/ranges_algo.h (shift_left, shift_right): Rename
	template parameters to use reserved name.
	* libsupc++/exception_ptr.h (exception_ptr): Likewise for
	parameters and local variables.
	* testsuite/17_intro/names.cc: Check "il". Do not check "d" and
	"y" in C++20 mode.
2020-10-08 00:05:53 +01:00
GCC Administrator
8e97b9052d Daily bump. 2020-10-07 00:16:35 +00:00
Jonathan Wakely
1352ea1925 libstdc++: Inline std::exception_ptr members [PR 90295]
This inlines most members of std::exception_ptr so that all operations
on a null exception_ptr can be optimized away. This benefits code like
std::future and coroutines where an exception_ptr object is present to
cope with exceptional cases, but is usually not used and remains null.

Since those functions were previously non-inline we have to continue to
export them from the library, for objects that were compiled against the
old headers and expect to find definitions in the library.

In order to inline the copy constructor and destructor we need to export
the _M_addref() and _M_release() members that increment/decrement the
reference count when copying/destroying a non-null exception_ptr. The
copy ctor and dtor check for null and don't call _M_addref and
_M_release unless they need to. The checks for null pointers in
_M_addref and _M_release are still needed because old code might call
them without checking for null first. But we can use __builtin_expect to
predict that they are usually called for the non-null case.

libstdc++-v3/ChangeLog:

	PR libstdc++/90295
	* config/abi/pre/gnu.ver (CXXABI_1.3.13): New symbol version.
	(exception_ptr::_M_addref(), exception_ptr::_M_release()):
	Export symbols.
	* libsupc++/eh_ptr.cc (exception_ptr::exception_ptr()):
	Remove out-of-line definition.
	(exception_ptr::exception_ptr(const exception_ptr&)):
	Likewise.
	(exception_ptr::~exception_ptr()): Likewise.
	(exception_ptr::operator=(const exception_ptr&)):
	Likewise.
	(exception_ptr::swap(exception_ptr&)): Likewise.
	(exception_ptr::_M_addref()): Add branch prediction.
	* libsupc++/exception_ptr.h (exception_ptr::operator bool):
	Add noexcept.
	[!_GLIBCXX_EH_PTR_COMPAT] (operator==, operator!=): Define
	inline as hidden friends. Remove declarations at namespace
	scope.
	(exception_ptr::exception_ptr()): Define inline.
	(exception_ptr::exception_ptr(const exception_ptr&)):
	Likewise.
	(exception_ptr::~exception_ptr()): Likewise.
	(exception_ptr::operator=(const exception_ptr&)):
	Likewise.
	(exception_ptr::swap(exception_ptr&)): Likewise.
	* testsuite/util/testsuite_abi.cc: Add CXXABI_1.3.13.
	* testsuite/18_support/exception_ptr/90295.cc: New test.
2020-10-06 17:24:16 +01:00
Jonathan Wakely
9065c4adab libstdc++: Avoid CTAD for std::ranges::join_view [LWG 3474]
In commit ef275d1f20 I implemented the
wrong resolution of LWG 3474. This removes the deduction guide and
alters the views::join factory to create the right type explicitly.

libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view): Remove deduction guide.
	(views::join): Add explicit template argument list to prevent
	deducing the wrong type.
	* testsuite/std/ranges/adaptors/join.cc: Move test for LWG 3474
	here, from ...
	* testsuite/std/ranges/adaptors/join_lwg3474.cc: Removed.
2020-10-06 09:41:40 +01:00
GCC Administrator
7e9282ae62 Daily bump. 2020-10-06 00:16:25 +00:00
Jonathan Wakely
9af65c2b90 libstdc++: Reduce uses of std::numeric_limits
This avoids unnecessary instantiations of std::numeric_limits or
inclusion of <limits> when a more lightweight alternative would work.
Some uses can be replaced with __gnu_cxx::__int_traits and some can just
use size_t(-1) directly where SIZE_MAX is needed.

libstdc++-v3/ChangeLog:

	* include/bits/regex.h: Use __int_traits<int> instead of
	std::numeric_limits<int>.
	* include/bits/uniform_int_dist.h: Use __int_traits<T>::__max
	instead of std::numeric_limits<T>::max().
	* include/bits/hashtable_policy.h: Use size_t(-1) instead of
	std::numeric_limits<size_t>::max().
	* include/std/regex: Include <ext/numeric_traits.h>.
	* include/std/string_view: Use typedef for __int_traits<int>.
	* src/c++11/hashtable_c++0x.cc: Use size_t(-1) instead of
	std::numeric_limits<size_t>::max().
	* testsuite/std/ranges/iota/96042.cc: Include <limits>.
	* testsuite/std/ranges/iota/difference_type.cc: Likewise.
	* testsuite/std/ranges/subrange/96042.cc: Likewise.
2020-10-06 00:05:11 +01:00
Jonathan Wakely
1c72f460e9 libstdc++: Minor header cleanup in <numeric>
When adding new features to <numeric> I included the required headers
adjacent to the new code. This cleans it up by moving all the includes
to the start of the file.

libstdc++-v3/ChangeLog:

	* include/std/numeric: Move all #include directives to the top
	of the header.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error line
	numbers.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
2020-10-05 22:46:46 +01:00
Jonathan Wakely
f92a504fdd libstdc++: Make allocators throw bad_array_new_length on overflow [LWG 3190]
std::allocator and std::pmr::polymorphic_allocator should throw
std::bad_array_new_length from their allocate member functions if the
number of bytes required cannot be represented in std::size_t.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver: Add new symbol.
	* include/bits/functexcept.h (__throw_bad_array_new_length):
	Declare new function.
	* include/ext/malloc_allocator.h (malloc_allocator::allocate):
	Throw bad_array_new_length for impossible sizes (LWG 3190).
	* include/ext/new_allocator.h (new_allocator::allocate):
	Likewise.
	* include/std/memory_resource (polymorphic_allocator::allocate)
	(polymorphic_allocator::allocate_object): Use new function,
	__throw_bad_array_new_length.
	* src/c++11/functexcept.cc (__throw_bad_array_new_length):
	Define.
	* testsuite/20_util/allocator/lwg3190.cc: New test.
2020-10-05 15:18:56 +01:00
Mike Crowe
f33a43f9f7 libstdc++: Use correct duration for atomic_futex wait on custom clock [PR 91486]
As Jonathan Wakely pointed out[1], my change in commit
f9ddb696a2 should have been rounding to
the target clock duration type rather than the input clock duration type
in __atomic_futex_unsigned::_M_load_when_equal_until just as (e.g.)
condition_variable does.

As well as fixing this, let's create a rather contrived test that fails
with the previous code, but unfortunately only when run on a machine
with an uptime of over 208.5 days, and even then not always.

[1] https://gcc.gnu.org/pipermail/libstdc++/2020-September/051004.html

libstdc++-v3/ChangeLog:

	PR libstdc++/91486
	* include/bits/atomic_futex.h:
	(__atomic_futex_unsigned::_M_load_when_equal_until): Use target
	clock duration type when rounding.
	* testsuite/30_threads/async/async.cc (test_pr91486_wait_for):
	Rename from test_pr91486.
	(float_steady_clock): New class for test.
	(test_pr91486_wait_until): New test.
2020-10-05 11:32:10 +01:00
Mike Crowe
d5243c4626 libstdc++: Test C++11 implementation of std::chrono::__detail::ceil
Commit 53ad6b1979 split the implementation
of std::chrono::__detail::ceil so that when compiling for C++17 and
later std::chrono::ceil is used but when compiling for earlier versions
a separate implementation is used to comply with C++11's limited
constexpr rules. Let's run the equivalent of the existing
std::chrono::ceil test cases on std::chrono::__detail::ceil too to make
sure that it doesn't get broken.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/duration_cast/rounding_c++11.cc: Copy
	rounding.cc and alter to support compilation for C++11 and to
	test std::chrono::__detail::ceil.
2020-10-05 11:09:03 +01:00
Jonathan Wakely
b98d3cc566 libstdc++: Add missing bugzilla PR numbers to ChangeLog
We missed these out of the git commit messages.
2020-10-05 10:46:25 +01:00
GCC Administrator
b0b9b8f02a Daily bump. 2020-10-03 00:16:25 +00:00
Jonathan Wakely
324118378e libstdc++: Change test to work without 64-bit atomics
This fixes a linker error for older ARM cores without 64-bit atomics.

I think the { dg-add-options libatomic } is no longer needed, but it's
harmless to keep it there.

libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/atomic_float/value_init.cc: Use float
	instead of double so that __atomic_load_8 isn't needed.
2020-10-02 22:18:51 +01:00
Jonathan Wakely
1ad08b64ce libstdc++: Fix testcase by using terminate handler
This test was supposed to verify that when __libc_single_threaded is
available we successfully detect recursive static initialization even
when linked to libpthread. But I forgot to that when recursive init is
detected, we terminate, and so the test fails.

This adds a terminate handler that exits cleanly, so the test passes
when recursive init is detected.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/96817.cc: Use terminate handler that
	calls _Exit(0).
2020-10-02 22:18:51 +01:00