Commit Graph

13065 Commits

Author SHA1 Message Date
GCC Administrator
280d2838c1 Daily bump. 2021-11-18 00:16:34 +00:00
Jonathan Wakely
0e4a8656e8 libstdc++: Fix author name in ChangeLog
The constexpr std::string commit was my own work, but the commit still
had the author name from an earlier cherry-pick that eventually got
entirely reverted. This fixes the name in the ChangeLog file.
2021-11-17 22:41:49 +00:00
Jonathan Wakely
5ea8803e65 libstdc++: Use std::construct_at in net::ip::address
Using placement-new isn't valid in constant expressions, so this
replaces it with std::construct_at (via the std::_Construct function
that is usable before C++20).

libstdc++-v3/ChangeLog:

	* include/experimental/internet (address): Use std::_Construct
	to initialize union members.
2021-11-17 17:28:52 +00:00
Jonathan Wakely
5a9572e486 libstdc++: Simplify std::string constructors
Several std::basic_string constructors dispatch to one of the
two-argument overloads of _M_construct, which then dispatches again to
_M_construct_aux to detect whether the arguments are iterators or not.
That then dispatches to one of _M_construct(size_type, char_type) or
_M_construct(Iter, Iter, iterator_traits<Iter>::iterator_category{}).

For most of those constructors this is a waste of time, because we know
the arguments are already iterators. For basic_string(const CharT*) and
basic_string(initializer_list<C>) we know that we call _M_construct with
two pointers, and for basic_string(const basic_string&) we call it with
two const_iterators.  Those constructors can call the three-argument
overload of _M_construct with the iterator category tag right away,
without the intermediate dispatching.

The case where this doesn't apply is basic_string(InputIter, InputIter),
but for C++11 and later this is constrained so we know it's an iterator
here as well. We can restrict the dispatching in this constructor to
only be done for C++98 and to call _M_construct_aux directly, which
allows us to remove the two-argument _M_construct(InputIter, InputIter)
overload entirely.

N.B. When calling the three-arg _M_construct with pointers or string
iterators, we pass forward_iterator_tag not random_access_iterator_tag.
This is because it makes no difference which overload gets called, and
simplifies overload resolution to not have to do a base-to-derived
check. If we ever add a new overload of M_construct for random access
iterators we would have to revisit this, but that seems unlikely.

This patch also moves the __is_null_pointer checks from the three-arg
_M_construct into the constructors where a null pointer argument is
actually possible. This avoids redundant checks where we know we have a
non-null pointer, or don't have a pointer at all.

Finally, this patch replaces some try-blocks with an RAII type, so that
memory is deallocated during unwinding. This avoids the overhead of
catching and rethrowing an exception.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (_M_construct_aux): Only define
	for C++98. Remove constexpr.
	(_M_construct_aux_2): Likewise.
	(_M_construct(InputIter, InputIter)): Remove.
	(basic_string(const basic_string&)): Call _M_construct with
	iterator category argument.
	(basic_string(const basic_string&, size_type, const Alloc&)):
	Likewise.
	(basic_string(const basic_string&, size_type, size_type)):
	Likewise.
	(basic_string(const charT*, size_type, const Alloc&)): Likewise.
	Check for null pointer.
	(basic_string(const charT*, const Alloc&)): Likewise.
	(basic_string(initializer_list<charT>, const Alloc&)): Call
	_M_construct with iterator category argument.
	(basic_string(const basic_string&, const Alloc&)): Likewise.
	(basic_string(basic_string&&, const Alloc&)): Likewise.
	(basic_string(_InputIter, _InputIter, const Alloc&)): Likewise
	for C++11 and later, call _M_construct_aux for C++98.
	* include/bits/basic_string.tcc
	(_M_construct(I, I, input_iterator_tag)): Replace try-block with
	RAII type.
	(_M_construct(I, I, forward_iterator_tag)): Likewise. Remove
	__is_null_pointer check.
2021-11-17 17:28:44 +00:00
Jonathan Wakely
6afa1083c6 libstdc++: Set active member of union in std::string [PR103295]
Clang diagnoses that the new constexpr std::string constructors are not
usable in constant expressions, because they start to write to members
of the union without setting an active member.

This adds a new helper function which returns the address of the local
buffer after making it the active member.

This doesn't fix all problems with Clang, because it still refuses to
write to memory returned by the allocator.

libstdc++-v3/ChangeLog:

	PR libstdc++/103295
	* include/bits/basic_string.h (_M_use_local_data()): New
	member function to make local buffer the active member.
	(assign(const basic_string&)): Use it.
	* include/bits/basic_string.tcc (_M_construct, reserve()):
	Likewise.
2021-11-17 17:21:25 +00:00
Jonathan Wakely
054bf99841 libstdc++: Fix std::type_info::before for ARM [PR103240]
The r179236 fix for std::type_info::operator== should also have been
applied to std::type_info::before. Otherwise two distinct types can
compare equivalent due to using a string comparison, when they should do
a pointer comparison.

libstdc++-v3/ChangeLog:

	PR libstdc++/103240
	* libsupc++/tinfo2.cc (type_info::before): Use unadjusted name
	to check for the '*' prefix.
	* testsuite/util/testsuite_shared.cc: Add type_info object for
	use in new test.
	* testsuite/18_support/type_info/103240.cc: New test.
2021-11-17 17:21:24 +00:00
GCC Administrator
6b1695f4a0 Daily bump. 2021-11-17 00:16:29 +00:00
Jonathan Wakely
73e4d9f175 libstdc++: Fix tests for constexpr std::string
Some tests fail when run with -D_GLIBCXX_USE_CXX11_ABI or -stdgnu++20.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (operator<=>): Use constexpr
	unconditionally.
	* testsuite/21_strings/basic_string/modifiers/constexpr.cc:
	Require cxx11-abit effective target.
	* testsuite/21_strings/headers/string/synopsis.cc: Add
	conditional constexpr to declarations, and adjust relational
	operators for C++20.
2021-11-16 22:48:15 +00:00
Patrick Palka
7461b58131 libstdc++: Merge latest Ryu sources
libstdc++-v3/ChangeLog:

	* src/c++17/ryu/MERGE: Update the commit hash.
	* src/c++17/ryu/d2s_intrinsics.h: Merge from Ryu's master
	branch.

Signed-off-by: Patrick Palka <ppalka@redhat.com>
2021-11-16 12:23:27 -05:00
Michael de Lang
b96e2ff9d8 libstdc++: Implement constexpr std::basic_string for C++20
This is only supported for the cxx11 ABI, not for COW strings.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (basic_string, operator""s): Add
	constexpr for C++20.
	(basic_string::basic_string(basic_string&&)): Only copy
	initialized portion of the buffer.
	(basic_string::basic_string(basic_string&&, const Alloc&)):
	Likewise.
	* include/bits/basic_string.tcc (basic_string): Add constexpr
	for C++20.
	(basic_string::swap(basic_string&)): Only copy initialized
	portions of the buffers.
	(basic_string::_M_replace): Add constexpr implementation that
	doesn't depend on pointer comparisons.
	* include/bits/cow_string.h: Adjust comment.
	* include/ext/type_traits.h (__is_null_pointer): Add constexpr.
	* include/std/string (erase, erase_if): Add constexpr.
	* include/std/version (__cpp_lib_constexpr_string): Update
	value.
	* testsuite/21_strings/basic_string/cons/char/constexpr.cc:
	New test.
	* testsuite/21_strings/basic_string/cons/wchar_t/constexpr.cc:
	New test.
	* testsuite/21_strings/basic_string/literals/constexpr.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/constexpr.cc: New test.
	* testsuite/21_strings/basic_string/modifiers/swap/char/constexpr.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/swap/wchar_t/constexpr.cc:
	New test.
	* testsuite/21_strings/basic_string/version.cc: New test.
2021-11-16 16:43:20 +00:00
Jonathan Wakely
59434931fb libstdc++: Use hidden friends for vector<bool>::reference swap overloads
These swap overloads are non-standard, but are needed to make swap work
for vector<bool>::reference rvalues. They don't need to be called
explicitly, only via ADL, so hide them from normal lookup. This is what
I've proposed as the resolution to LWG 3638.

libstdc++-v3/ChangeLog:

	* include/bits/stl_bvector.h (swap(_Bit_reference, _Bit_reference))
	(swap(_Bit_reference, bool&), swap(bool&, _Bit_reference)):
	Define as hidden friends of _Bit_reference.
2021-11-16 16:42:59 +00:00
Jonathan Wakely
8d8e8f3ad5 libstdc++: Fix out-of-bound array accesses in testsuite
I fixed some undefined behaviour in string tests in r238609, but I only
fixed the narrow char versions. This applies the same fixes to the
wchar_t ones. These problems were found when testing a patch to make
std::basic_string usable in constexpr.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/modifiers/append/wchar_t/1.cc:
	Fix reads past the end of strings.
	* testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc:
	Likewise.
	* testsuite/experimental/string_view/operations/compare/wchar_t/1.cc:
	Likewise.
2021-11-16 14:09:00 +00:00
Jonathan Wakely
9719769471 libstdc++: Fix typos in tests
libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/allocator/71964.cc: Fix
	typo.
	* testsuite/23_containers/set/allocator/71964.cc: Likewise.
2021-11-16 14:08:42 +00:00
GCC Administrator
e2b57363fc Daily bump. 2021-11-16 00:16:31 +00:00
Jason Merrill
87c2080b05 c++: Add -fimplicit-constexpr
With each successive C++ standard the restrictions on the use of the
constexpr keyword for functions get weaker and weaker; it recently occurred
to me that it is heading toward the same fate as the C register keyword,
which was once useful for optimization but became obsolete.  Similarly, it
seems to me that we should be able to just treat inlines as constexpr
functions and not make people add the extra keyword everywhere.

There were a lot of testcase changes needed; many disabling errors about
non-constexpr functions that are now constexpr, and many disabling implicit
constexpr so that the tests can check the same thing as before, whether
that's mangling or whatever.

gcc/c-family/ChangeLog:

	* c.opt: Add -fimplicit-constexpr.
	* c-cppbuiltin.c: Define __cpp_implicit_constexpr.
	* c-opts.c (c_common_post_options): Disable below C++14.

gcc/cp/ChangeLog:

	* cp-tree.h (struct lang_decl_fn): Add implicit_constexpr.
	(decl_implicit_constexpr_p): New.
	* class.c (type_maybe_constexpr_destructor): Use
	TYPE_HAS_TRIVIAL_DESTRUCTOR and maybe_constexpr_fn.
	(finalize_literal_type_property): Simplify.
	* constexpr.c (is_valid_constexpr_fn): Check for dtor.
	(maybe_save_constexpr_fundef): Try to set DECL_DECLARED_CONSTEXPR_P
	on inlines.
	(cxx_eval_call_expression): Use maybe_constexpr_fn.
	(maybe_constexpr_fn): Handle flag_implicit_constexpr.
	(var_in_maybe_constexpr_fn): Use maybe_constexpr_fn.
	(potential_constant_expression_1): Likewise.
	(decl_implicit_constexpr_p): New.
	* decl.c (validate_constexpr_redeclaration): Allow change with
	-fimplicit-constexpr.
	(grok_special_member_properties): Use maybe_constexpr_fn.
	* error.c (dump_function_decl): Don't print 'constexpr'
	if it's implicit.
	* Make-lang.in (check-c++-all): Update.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/to_address/1_neg.cc: Adjust error.
	* testsuite/26_numerics/random/concept.cc: Adjust asserts.

gcc/testsuite/ChangeLog:

	* lib/g++-dg.exp: Handle "impcx".
	* lib/target-supports.exp
	(check_effective_target_implicit_constexpr): New.
	* g++.dg/abi/abi-tag16.C:
	* g++.dg/abi/abi-tag18a.C:
	* g++.dg/abi/guard4.C:
	* g++.dg/abi/lambda-defarg1.C:
	* g++.dg/abi/mangle26.C:
	* g++.dg/cpp0x/constexpr-diag3.C:
	* g++.dg/cpp0x/constexpr-ex1.C:
	* g++.dg/cpp0x/constexpr-ice5.C:
	* g++.dg/cpp0x/constexpr-incomplete2.C:
	* g++.dg/cpp0x/constexpr-memfn1.C:
	* g++.dg/cpp0x/constexpr-neg3.C:
	* g++.dg/cpp0x/constexpr-specialization.C:
	* g++.dg/cpp0x/inh-ctor19.C:
	* g++.dg/cpp0x/inh-ctor30.C:
	* g++.dg/cpp0x/lambda/lambda-mangle3.C:
	* g++.dg/cpp0x/lambda/lambda-mangle5.C:
	* g++.dg/cpp1y/auto-fn12.C:
	* g++.dg/cpp1y/constexpr-loop5.C:
	* g++.dg/cpp1z/constexpr-lambda7.C:
	* g++.dg/cpp2a/constexpr-dtor3.C:
	* g++.dg/cpp2a/constexpr-new13.C:
	* g++.dg/cpp2a/constinit11.C:
	* g++.dg/cpp2a/constinit12.C:
	* g++.dg/cpp2a/constinit14.C:
	* g++.dg/cpp2a/constinit15.C:
	* g++.dg/cpp2a/spaceship-constexpr1.C:
	* g++.dg/cpp2a/spaceship-eq3.C:
	* g++.dg/cpp2a/udlit-class-nttp-neg2.C:
	* g++.dg/debug/dwarf2/auto1.C:
	* g++.dg/debug/dwarf2/cdtor-1.C:
	* g++.dg/debug/dwarf2/lambda1.C:
	* g++.dg/debug/dwarf2/pr54508.C:
	* g++.dg/debug/dwarf2/pubnames-2.C:
	* g++.dg/debug/dwarf2/pubnames-3.C:
	* g++.dg/ext/is_literal_type3.C:
	* g++.dg/ext/visibility/template7.C:
	* g++.dg/gcov/gcov-12.C:
	* g++.dg/gcov/gcov-2.C:
	* g++.dg/ipa/devirt-35.C:
	* g++.dg/ipa/devirt-36.C:
	* g++.dg/ipa/devirt-37.C:
	* g++.dg/ipa/devirt-44.C:
	* g++.dg/ipa/imm-devirt-1.C:
	* g++.dg/lookup/builtin5.C:
	* g++.dg/lto/inline-crossmodule-1_0.C:
	* g++.dg/modules/enum-1_a.C:
	* g++.dg/modules/fn-inline-1_c.C:
	* g++.dg/modules/pmf-1_b.C:
	* g++.dg/modules/used-1_c.C:
	* g++.dg/tls/thread_local11.C:
	* g++.dg/tls/thread_local11a.C:
	* g++.dg/tm/pr46653.C:
	* g++.dg/ubsan/pr70035.C:
	* g++.old-deja/g++.other/delete6.C:
	* g++.dg/modules/pmf-1_a.H:
	Adjust for implicit constexpr.
2021-11-15 18:50:07 -05:00
François Dumont
d10b863fa3 libstdc++: Unordered containers merge re-use hash code
When merging 2 unordered containers with same hasher we can re-use the hash code from
the cache if any.

Also in the context of the merge operation on multi-container use previous insert iterator as a hint
for the next insert.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h:
	(_Hash_code_base<>::_M_hash_code(const _Hash&, const _Hash_node_value<_Value, true>&)): New.
	(_Hash_code_base<>::_M_hash_code<_H2>(const _H2&, const _Hash_node_value<>&)): New.
	* include/bits/hashtable.h (_Hashtable<>::_M_merge_unique): Use latter.
	(_Hashtable<>::_M_merge_multi): Likewise.
	* testsuite/23_containers/unordered_multiset/modifiers/merge.cc (test05): New test.
	* testsuite/23_containers/unordered_set/modifiers/merge.cc (test04): New test.
2021-11-15 18:52:07 +01:00
Jason Merrill
37326651b4 c++: check constexpr constructor body
The implicit constexpr patch revealed that our checks for constexpr
constructors that could possibly produce a constant value (which
otherwise are IFNDR) was failing to look at most of the function body.
Fixing that required some library tweaks.

gcc/cp/ChangeLog:

	* constexpr.c (maybe_save_constexpr_fundef): Also check whether the
	body of a constructor is potentially constant.

libstdc++-v3/ChangeLog:

	* src/c++17/memory_resource.cc: Add missing constexpr.
	* include/experimental/internet: Only mark copy constructor
	as constexpr with __cpp_constexpr_dynamic_alloc.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/constexpr-89285-2.C: Expect error.
	* g++.dg/cpp1y/constexpr-89285.C: Adjust error.
2021-11-15 02:50:45 -05:00
GCC Administrator
b85a03ae11 Daily bump. 2021-11-15 00:16:20 +00:00
François Dumont
e9a53a4f76 libstdc++: [_GLIBCXX_DEBUG] Remove _Safe_container<>::_M_safe()
_GLIBCXX_DEBUG container code cleanup to get rid of _Safe_container<>::_M_safe() and just
use _Safe:: calls which use normal inheritance. Also remove several usages of _M_base()
which can be most of the time ommitted and sometimes replace with explicit _Base::
calls.

libstdc++-v3/ChangeLog:

	* include/debug/safe_container.h (_Safe_container<>::_M_safe): Remove.
	* include/debug/deque (deque::operator=(initializer_list<>)): Replace
	_M_base() call with _Base:: call.
	(deque::operator[](size_type)): Likewise.
	* include/debug/forward_list (forward_list(forward_list&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(forward_list::operator=(initializer_list<>)): Remove _M_base() calls.
	(forward_list::splice_after, forward_list::merge): Likewise.
	* include/debug/list (list(list&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(list::operator=(initializer_list<>)): Remove _M_base() calls.
	(list::splice, list::merge): Likewise.
	* include/debug/map.h (map(map&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(map::operator=(initializer_list<>)): Remove _M_base() calls.
	* include/debug/multimap.h (multimap(multimap&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(multimap::operator=(initializer_list<>)): Remove _M_base() calls.
	* include/debug/set.h (set(set&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(set::operator=(initializer_list<>)): Remove _M_base() calls.
	* include/debug/multiset.h (multiset(multiset&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(multiset::operator=(initializer_list<>)): Remove _M_base() calls.
	* include/debug/string (basic_string(basic_string&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(basic_string::operator=(initializer_list<>)): Remove _M_base() call.
	(basic_string::operator=(const _CharT*), basic_string::operator=(_CharT)): Likewise.
	(basic_string::operator[](size_type), basic_string::operator+=(const basic_string&)):
	Likewise.
	(basic_string::operator+=(const _Char*), basic_string::operator+=(_CharT)): Likewise.
	* include/debug/unordered_map (unordered_map(unordered_map&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(unordered_map::operator=(initializer_list<>), unordered_map::merge):
	Remove _M_base() calls.
	(unordered_multimap(unordered_multimap&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(unordered_multimap::operator=(initializer_list<>), unordered_multimap::merge):
	Remove _M_base() calls.
	* include/debug/unordered_set (unordered_set(unordered_set&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(unordered_set::operator=(initializer_list<>), unordered_set::merge):
	Remove _M_base() calls.
	(unordered_multiset(unordered_multiset&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(unordered_multiset::operator=(initializer_list<>), unordered_multiset::merge):
	Remove _M_base() calls.
	* include/debug/vector (vector(vector&&, const allocator_type&)):
	Remove _M_safe() and _M_base() calls.
	(vector::operator=(initializer_list<>)): Remove _M_base() calls.
	(vector::operator[](size_type)): Likewise.
2021-11-14 21:55:01 +01:00
GCC Administrator
a8029add30 Daily bump. 2021-11-14 00:16:23 +00:00
Jonathan Wakely
a30a2e43e4 libstdc++: Implement std::spanstream for C++23
This implements the <spanstream> header, as proposed for C++23 by P0448R4.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add spanstream header.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Add spanstream header.
	* include/std/version (__cpp_lib_spanstream): Define.
	* include/std/spanstream: New file.
	* testsuite/27_io/spanstream/1.cc: New test.
	* testsuite/27_io/spanstream/version.cc: New test.
2021-11-13 11:45:31 +00:00
Hans-Peter Nilsson
60f761c7e5 libstdc++: Use GCC_TRY_COMPILE_OR_LINK for getentropy, arc4random
Since r12-5056-g3439657b0286, there has been a regression in
test results; an additional 100 FAILs running the g++ and
libstdc++ testsuite on cris-elf, a newlib target.  The
failures are linker errors, not finding a definition for
getentropy.  It appears newlib has since 2017-12-03
declarations of getentropy and arc4random, and provides an
implementation of arc4random using getentropy, but provides no
definition of getentropy, not even a stub yielding ENOSYS.
This is similar to what it does for many other functions too.

While fixing newlib (like adding said stub) would likely help,
it still leaves older newlib releases hanging.  Thankfully,
the libstdc++ configury test can be improved to try linking
where possible; using the bespoke GCC_TRY_COMPILE_OR_LINK
instead of AC_TRY_COMPILE.  BTW, I see a lack of consistency;
some tests use AC_TRY_COMPILE and some GCC_TRY_COMPILE_OR_LINK
for no apparent reason, but this commit just amends
r12-5056-g3439657b0286.

libstdc++-v3:
	PR libstdc++/103166
	* acinclude.m4 (GLIBCXX_CHECK_GETENTROPY, GLIBCXX_CHECK_ARC4RANDOM):
	Use GCC_TRY_COMPILE_OR_LINK instead of AC_TRY_COMPILE.
	* configure: Regenerate.
2021-11-13 01:45:06 +01:00
GCC Administrator
af2852b9dc Daily bump. 2021-11-13 00:16:39 +00:00
Jonathan Wakely
a54ce8865a libstdc++: Print assertion messages to stderr [PR59675]
This replaces the printf used by failed debug assertions with fprintf,
so we can write to stderr.

To avoid including <stdio.h> the assert function is moved into the
library. To avoid programs using a vague linkage definition of the old
inline function, the function is renamed. Code compiled with old
versions of GCC might still call the old function, but code compiled
with the newer GCC will call the new function and write to stderr.

libstdc++-v3/ChangeLog:

	PR libstdc++/59675
	* acinclude.m4 (libtool_VERSION): Bump version.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Add version and
	export new symbol.
	* configure: Regenerate.
	* include/bits/c++config (__replacement_assert): Remove, declare
	__glibcxx_assert_fail instead.
	* src/c++11/debug.cc (__glibcxx_assert_fail): New function to
	replace __replacement_assert, writing to stderr instead of
	stdout.
	* testsuite/util/testsuite_abi.cc: Update latest version.
2021-11-12 12:23:10 +00:00
Jonathan Wakely
1ae8edf5f7 libstdc++: Implement constexpr std::vector for C++20
This implements P1004R2 ("Making std::vector constexpr") for C++20.

For now, debug mode vectors are not supported in constant expressions.
To make that work we might need to disable all attaching/detaching of
safe iterators. That can be fixed later.

Co-authored-by: Josh Marshall <joshua.r.marshall.1991@gmail.com>

libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h (_Destroy): Make constexpr for
	C++20 mode.
	* include/bits/allocator.h (__shrink_to_fit::_S_do_it):
	Likewise.
	* include/bits/stl_algobase.h (__fill_a1): Declare _Bit_iterator
	overload constexpr for C++20.
	* include/bits/stl_bvector.h (_Bit_type, _S_word_bit): Move out
	of inline namespace.
	(_Bit_reference, _Bit_iterator_base, _Bit_iterator)
	(_Bit_const_iterator, _Bvector_impl_data, _Bvector_base)
	(vector<bool, A>>): Add constexpr to every member function.
	(_Bvector_base::_M_allocate): Initialize storage during constant
	evaluation.
	(vector<bool, A>::_M_initialize_value): Use __fill_bvector_n
	instead of memset.
	(__fill_bvector_n): New helper function to replace memset during
	constant evaluation.
	* include/bits/stl_uninitialized.h (__uninitialized_copy<false>):
	Move logic to ...
	(__do_uninit_copy): New function.
	(__uninitialized_fill<false>): Move logic to ...
	(__do_uninit_fill): New function.
	(__uninitialized_fill_n<false>): Move logic to ...
	(__do_uninit_fill_n): New function.
	(__uninitialized_copy_a): Add constexpr. Use __do_uninit_copy.
	(__uninitialized_move_a, __uninitialized_move_if_noexcept_a):
	Add constexpr.
	(__uninitialized_fill_a): Add constexpr. Use __do_uninit_fill.
	(__uninitialized_fill_n_a): Add constexpr. Use
	__do_uninit_fill_n.
	(__uninitialized_default_n, __uninitialized_default_n_a)
	(__relocate_a_1, __relocate_a): Add constexpr.
	* include/bits/stl_vector.h (_Vector_impl_data, _Vector_impl)
	(_Vector_base, vector): Add constexpr to every member function.
	(_Vector_impl::_S_adjust): Disable ASan annotation during
	constant evaluation.
	(_Vector_base::_S_use_relocate): Disable bitwise-relocation
	during constant evaluation.
	(vector::_Temporary_value): Use a union for storage.
	* include/bits/vector.tcc (vector, vector<bool>): Add constexpr
	to every member function.
	* include/std/vector (erase_if, erase): Add constexpr.
	* testsuite/23_containers/headers/vector/synopsis.cc: Add
	constexpr for C++20 mode.
	* testsuite/23_containers/vector/bool/cmp_c++20.cc: Change to
	compile-only test using constant expressions.
	* testsuite/23_containers/vector/bool/capacity/29134.cc: Adjust
	namespace for _S_word_bit.
	* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc:
	Likewise.
	* testsuite/23_containers/vector/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/vector/cons/89164.cc: Adjust errors
	for C++20 and move C++17 test to ...
	* testsuite/23_containers/vector/cons/89164_c++17.cc: ... here.
	* testsuite/23_containers/vector/bool/capacity/constexpr.cc: New test.
	* testsuite/23_containers/vector/bool/cons/constexpr.cc: New test.
	* testsuite/23_containers/vector/bool/element_access/constexpr.cc: New test.
	* testsuite/23_containers/vector/bool/modifiers/assign/constexpr.cc: New test.
	* testsuite/23_containers/vector/bool/modifiers/constexpr.cc: New test.
	* testsuite/23_containers/vector/bool/modifiers/swap/constexpr.cc: New test.
	* testsuite/23_containers/vector/capacity/constexpr.cc: New test.
	* testsuite/23_containers/vector/cons/constexpr.cc: New test.
	* testsuite/23_containers/vector/data_access/constexpr.cc: New test.
	* testsuite/23_containers/vector/element_access/constexpr.cc: New test.
	* testsuite/23_containers/vector/modifiers/assign/constexpr.cc: New test.
	* testsuite/23_containers/vector/modifiers/constexpr.cc: New test.
	* testsuite/23_containers/vector/modifiers/swap/constexpr.cc: New test.
2021-11-12 00:42:39 +00:00
GCC Administrator
b39265d4fe Daily bump. 2021-11-12 00:16:32 +00:00
Jonathan Wakely
4a407d358e libstdc++: Fix debug containers for C++98 mode
Since r12-5072 made _Safe_container::operator=(const _Safe_container&)
protected, the debug containers no longer compile in C++98 mode. They
have user-provided copy assignment operators in C++98 mode, and they
assign each base class in turn. The 'this->_M_safe() = __x' expressions
fail, because calling a protected member function is only allowed via
'this'. They could be fixed by using this->_Safe::operator=(__x) but a
simpler solution is to just remove the user-provided assignment
operators and let the compiler define them (as we do for C++11 and
later, by defining them as defaulted).

The only change needed for that to work is to define the _Safe_vector
copy assignment operator in C++98 mode, so that the implicit
__gnu_debug::vector::operator= definition will call it, instead of
needing to call _M_update_guaranteed_capacity() manually.

libstdc++-v3/ChangeLog:

	* include/debug/deque (deque::operator=(const deque&)): Remove
	definition.
	* include/debug/list (list::operator=(const list&)): Likewise.
	* include/debug/map.h (map::operator=(const map&)): Likewise.
	* include/debug/multimap.h (multimap::operator=(const multimap&)):
	Likewise.
	* include/debug/multiset.h (multiset::operator=(const multiset&)):
	Likewise.
	* include/debug/set.h (set::operator=(const set&)): Likewise.
	* include/debug/string (basic_string::operator=(const basic_string&)):
	Likewise.
	* include/debug/vector (vector::operator=(const vector&)):
	Likewise.
	(_Safe_vector::operator=(const _Safe_vector&)): Define for
	C++98 as well.
2021-11-11 21:55:11 +00:00
Jonathan Wakely
083fd73202 libstdc++: Make pmr::memory_resource::allocate implicitly create objects
Calling the placement version of ::operator new "implicitly creates
objects in the returned region of storage" as per [intro.object]. This
allows the returned memory to be used as storage for implicit-lifetime
types (including arrays) without additional action by the caller. This
is required by the proposed resolution of LWG 3147.

libstdc++-v3/ChangeLog:

	* include/std/memory_resource (memory_resource::allocate):
	Implicitly create objects in the returned storage.
2021-11-11 18:16:17 +00:00
Jonathan Wakely
ef0e100f58 libstdc++: Remove public std::vector<bool>::data() member
This function only exists to avoid an error in the debug mode vector, so
doesn't need to be public.

libstdc++-v3/ChangeLog:

	* include/bits/stl_bvector.h (vector<bool>::data()): Give
	protected access, and delete for C++11 and later.
2021-11-11 18:16:17 +00:00
GCC Administrator
8d36a0d288 Daily bump. 2021-11-11 00:16:28 +00:00
Jonathan Wakely
77963796ae libstdc++: Fix test for libstdc++ not including <unistd.h> [PR100117]
The <cxxx> headers for the C library are not under our control, so we
can't prevent them from including <unistd.h>. Change the PR 49745 test
to only include the C++ library headers, not the <cxxx> ones.

To ensure <bits/stdc++.h> isn't included automatically we need to use
no_pch to disable PCH.

libstdc++-v3/ChangeLog:

	PR libstdc++/100117
	* testsuite/17_intro/headers/c++1998/49745.cc: Explicitly list
	all C++ headers instead of including <bits/stdc++.h>
2021-11-10 12:03:29 +00:00
Jonathan Wakely
80fe172ba9 libstdc++: Disable gthreads weak symbols for glibc 2.34 [PR103133]
Since Glibc 2.34 all pthreads symbols are defined directly in libc not
libpthread, and since Glibc 2.32 we have used __libc_single_threaded to
avoid unnecessary locking in single-threaded programs. This means there
is no reason to avoid linking to libpthread now, and so no reason to use
weak symbols defined in gthr-posix.h for all the pthread_xxx functions.

libstdc++-v3/ChangeLog:

	PR libstdc++/100748
	PR libstdc++/103133
	* config/os/gnu-linux/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK):
	Define for glibc 2.34 and later.
2021-11-10 12:01:27 +00:00
GCC Administrator
c9b1334eec Daily bump. 2021-11-10 00:16:28 +00:00
François Dumont
f4b4ce152a libstdc++: [_GLIBCXX_DEBUG] Implement unordered container merge
The _GLIBCXX_DEBUG unordered containers need a dedicated merge implementation
so that any existing iterator on the transfered nodes is properly invalidated.

Add typedef/using declarations for everything used as-is from normal implementation.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h (__distance_fw): Replace class keyword with
	typename.
	* include/bits/hashtable.h (_Hashtable<>::_M_merge_unique): Remove noexcept
	qualification. Use const_iterator for node extraction/reinsert.
	(_Hashtable<>::_M_merge_multi): Likewise. Compute new hash code before extract.
	* include/debug/safe_container.h (_Safe_container<>): Make all methods
	protected.
	* include/debug/safe_unordered_container.h
	(_Safe_unordered_container<>::_UContInvalidatePred<_ExtractKey, _Source>): New.
	(_Safe_unordered_container<>::_UMContInvalidatePred<_ExtractKey, _Source>): New.
	(_Safe_unordered_container<>::_UContMergeGuard<_Source, _InvalidatePred>): New.
	(_Safe_unordered_container<>::_S_uc_guard<_ExtractKey, _Source>): New.
	(_Safe_unordered_container<>::_S_umc_guard<_ExtractKey, _Source>): New.
	(_Safe_unordered_container<>::_M_invalide_all): Make public.
	(_Safe_unordered_container<>::_M_invalide_if): Likewise.
	(_Safe_unordered_container<>::_M_invalide_local_if): Likewise.
	* include/debug/unordered_map
	(unordered_map<>::mapped_type, pointer, const_pointer): New typedef.
	(unordered_map<>::reference, const_reference, difference_type): New typedef.
	(unordered_map<>::get_allocator, empty, size, max_size): Add usings.
	(unordered_map<>::bucket_count, max_bucket_count, bucket): Add usings.
	(unordered_map<>::hash_function, key_equal, count, contains): Add usings.
	(unordered_map<>::operator[], at, rehash, reserve): Add usings.
	(unordered_map<>::merge): New.
	(unordered_multimap<>::mapped_type, pointer, const_pointer): New typedef.
	(unordered_multimap<>::reference, const_reference, difference_type): New typedef.
	(unordered_multimap<>::get_allocator, empty, size, max_size): Add usings.
	(unordered_multimap<>::bucket_count, max_bucket_count, bucket): Add usings.
	(unordered_multimap<>::hash_function, key_equal, count, contains): Add usings.
	(unordered_multimap<>::rehash, reserve): Add usings.
	(unordered_multimap<>::merge): New.
	* include/debug/unordered_set
	(unordered_set<>::mapped_type, pointer, const_pointer): New typedef.
	(unordered_set<>::reference, const_reference, difference_type): New typedef.
	(unordered_set<>::get_allocator, empty, size, max_size): Add usings.
	(unordered_set<>::bucket_count, max_bucket_count, bucket): Add usings.
	(unordered_set<>::hash_function, key_equal, count, contains): Add usings.
	(unordered_set<>::rehash, reserve): Add usings.
	(unordered_set<>::merge): New.
	(unordered_multiset<>::mapped_type, pointer, const_pointer): New typedef.
	(unordered_multiset<>::reference, const_reference, difference_type): New typedef.
	(unordered_multiset<>::get_allocator, empty, size, max_size): Add usings.
	(unordered_multiset<>::bucket_count, max_bucket_count, bucket): Add usings.
	(unordered_multiset<>::hash_function, key_equal, count, contains): Add usings.
	(unordered_multiset<>::rehash, reserve): Add usings.
	(unordered_multiset<>::merge): New.
	* testsuite/23_containers/unordered_map/debug/merge1_neg.cc: New test.
	* testsuite/23_containers/unordered_map/debug/merge2_neg.cc: New test.
	* testsuite/23_containers/unordered_map/debug/merge3_neg.cc: New test.
	* testsuite/23_containers/unordered_map/debug/merge4_neg.cc: New test.
	* testsuite/23_containers/unordered_multimap/debug/merge1_neg.cc: New test.
	* testsuite/23_containers/unordered_multimap/debug/merge2_neg.cc: New test.
	* testsuite/23_containers/unordered_multimap/debug/merge3_neg.cc: New test.
	* testsuite/23_containers/unordered_multimap/debug/merge4_neg.cc: New test.
	* testsuite/23_containers/unordered_multiset/debug/merge1_neg.cc: New test.
	* testsuite/23_containers/unordered_multiset/debug/merge2_neg.cc: New test.
	* testsuite/23_containers/unordered_multiset/debug/merge3_neg.cc: New test.
	* testsuite/23_containers/unordered_multiset/debug/merge4_neg.cc: New test.
	* testsuite/23_containers/unordered_set/debug/merge1_neg.cc: New test.
	* testsuite/23_containers/unordered_set/debug/merge2_neg.cc: New test.
	* testsuite/23_containers/unordered_set/debug/merge3_neg.cc: New test.
	* testsuite/23_containers/unordered_set/debug/merge4_neg.cc: New test.
	* testsuite/util/testsuite_abi.h: [_GLIBCXX_DEBUG] Use normal unordered
	container implementation.
2021-11-09 21:50:17 +01:00
Jonathan Wakely
95e8fcd3d5 libstdc++: Make test print which random_device tokens work
libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/random/random_device/cons/token.cc:
	Print results of random_device_available checks.
2021-11-09 15:12:29 +00:00
Jonathan Wakely
d9ebf0ce08 libstdc++: Do not use 64-bit DARN on 32-bit powerpc [PR103146]
We need to use the 64-bit DARN to detect failure without bias, but it's
not available in 32-bit mode.

libstdc++-v3/ChangeLog:

	PR libstdc++/103146
	* src/c++11/random.cc: Check __powerpc64__ not __powerpc__.
2021-11-09 14:40:33 +00:00
Jonathan Wakely
3439657b02 libstdc++: Support getentropy and arc4random in std::random_device
This adds additional "getentropy" and "arc4random" tokens to
std::random_device. The former is supported on Glibc and OpenBSD (and
apparently wasm), and the latter is supported on various BSDs.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CHECK_GETENTROPY, GLIBCXX_CHECK_ARC4RANDOM):
	Define.
	* configure.ac (GLIBCXX_CHECK_GETENTROPY, GLIBCXX_CHECK_ARC4RANDOM):
	Use them.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* src/c++11/random.cc (random_device): Add getentropy and
	arc4random as sources.
	* testsuite/26_numerics/random/random_device/cons/token.cc:
	Check new tokens.
	* testsuite/26_numerics/random/random_device/entropy.cc:
	Likewise.
2021-11-09 14:40:33 +00:00
Jonathan Wakely
8d2d0a6c43 libstdc++: Make spurious std::random_device FAIL less likely
It's possible that independent reads from /dev/random and /dev/urandom
could produce the same value by chance. Retry if that happens. The
chances of it happening twice are miniscule.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/random/random_device/cons/token.cc:
	Retry if random devices produce the same value.
2021-11-09 14:40:33 +00:00
Rasmus Villemoes
cc6b8cd9a2 libstdc++: only define _GLIBCXX_HAVE_TLS for VxWorks >= 6.6
According to
https://gcc.gnu.org/legacy-ml/gcc-patches/2008-03/msg01698.html, the
TLS support, including the __tls_lookup function, was added to VxWorks
in 6.6.

It certainly doesn't exist on our VxWorks 5 platform, but the fallback
code in eh_globals.cc using __gthread_key_create() etc. used to work
just fine.

libstdc++-v3/ChangeLog:

	* config/os/vxworks/os_defines.h (_GLIBCXX_HAVE_TLS): Only
	define for VxWorks >= 6.6.
2021-11-09 09:51:08 +01:00
GCC Administrator
851dff042a Daily bump. 2021-11-06 00:16:24 +00:00
Jonathan Wakely
2b2d97fc54 libstdc++: Fix inconsistent noexcept-specific for valarray begin/end
These declarations should be noexcept after I added it to the
definitions in <valarray>.

libstdc++-v3/ChangeLog:

	* include/bits/range_access.h (begin(valarray), end(valarray)):
	Add noexcept.
2021-11-05 21:44:01 +00:00
Jonathan Wakely
70d6f6e41f libstdc++: Fix pack expansions in tuple_size_v specializations
libstdc++-v3/ChangeLog:

	* include/std/tuple (tuple_size_v): Fix pack expansion.
2021-11-05 21:44:00 +00:00
Jonathan Wakely
2627e3b7fd libstdc++: Add [[unlikely]] attributes to std::random_device routines
libstdc++-v3/ChangeLog:

	* src/c++11/random.cc (__x86_rdrand, __x86_rdseed): Add
	[[unlikely]] attribute.
2021-11-05 18:14:41 +00:00
Jonathan Wakely
5997e6a6ec libstdc++: Add support for POWER9 DARN instruction to std::random_device
The ISA-3.0 instruction set includes DARN ("deliver a random number")
which can be used similarly to the existing support for RDRAND and RDSEED.

libstdc++-v3/ChangeLog:

	* src/c++11/random.cc [__powerpc__] (USE_DARN): Define.
	(__ppc_darn): New function to use POWER9 DARN instruction.
	(Which): Add 'darn' enumerator.
	(which_source): Check for __ppc_darn.
	(random_device::_M_init): Support "darn" and "hw" tokens.
	(random_device::_M_getentropy): Add darn to switch.
	* testsuite/26_numerics/random/random_device/cons/token.cc:
	Check "darn" token.
	* testsuite/26_numerics/random/random_device/entropy.cc:
	Likewise.
2021-11-05 18:14:40 +00:00
Jonathan Wakely
30b8ec68e2 libstdc++: Add xfail to pretty printer tests that fail in C++20
For some reason the type printer for std::string doesn't work in C++20
mode, so std::basic_string<char, char_traits<char>, allocator<char> is
printed out in full rather than being shown as std::string. It's
probably related to the fact that the extern template declarations are
disabled for C++20, but I don't know why that affects GDB.

For now I'm just marking the relevant tests as XFAIL. That requires
adding support for target selectors to individual GDB directives such as
note-test and whatis-regexp-test.

libstdc++-v3/ChangeLog:

	* testsuite/lib/gdb-test.exp: Add target selector support to the
	dg-final directives.
	* testsuite/libstdc++-prettyprinters/80276.cc: Add xfail for
	C++20.
	* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/prettyprinters.exp: Tweak
	comment.
2021-11-05 12:22:31 +00:00
GCC Administrator
29a1af24ef Daily bump. 2021-11-05 00:16:36 +00:00
Jonathan Wakely
a634928f5c libstdc++: Fix pretty printing of std::unique_ptr [PR103086]
Since std::tuple started using [[no_unique_address]] the tuple<T*, D>
member of std::unique_ptr<T, D> has two _M_head_impl subobjects, in
different base classes. That means this printer code is ambiguous:

    tuple_head_type = tuple_impl_type.fields()[1].type   # _Head_base
    head_field = tuple_head_type.fields()[0]
    if head_field.name == '_M_head_impl':
        self.pointer = tuple_member['_M_head_impl']

In older versions of GDB it happened to work by chance, because GDB
returned the last _M_head_impl member and std::tuple's base classes are
stored in reverse order, so the last one was the T* element of the
tuple. Since GDB 11 it returns the first _M_head_impl, which is the
deleter element.

The fix is for the printer to stop using an ambiguous field name and
cast the tuple to the correct base class before accessing the
_M_head_impl member.

Instead of fixing this in both UniquePointerPrinter and StdPathPrinter a
new unique_ptr_get function is defined to do it correctly. That is
defined in terms of new tuple_get and _tuple_impl_get functions.

It would be possible to reuse _tuple_impl_get to access each element in
StdTuplePrinter._iterator.__next__, but that already does the correct
casting, and wouldn't be much simpler anyway.

libstdc++-v3/ChangeLog:

	PR libstdc++/103086
	* python/libstdcxx/v6/printers.py (_tuple_impl_get): New helper
	for accessing the tuple element stored in a _Tuple_impl node.
	(tuple_get): New function for accessing a tuple element.
	(unique_ptr_get): New function for accessing a unique_ptr.
	(UniquePointerPrinter, StdPathPrinter): Use unique_ptr_get.
	* python/libstdcxx/v6/xmethods.py (UniquePtrGetWorker): Cast
	tuple to its base class before accessing _M_head_impl.
2021-11-04 22:50:02 +00:00
Jonathan Wakely
f4130a3eb5 libstdc++: Deprecate std::unexpected and handler functions
These functions have been deprecated since C++11, and were removed in
C++17. The proposal P0323 wants to reuse the name std::unexpected for a
class template, so we will need to stop defining the current function
for C++23 anyway.

This marks them as deprecated for C++11 and up, to warn users they won't
continue to be available. It disables them for C++17 and up, unless the
_GLIBCXX_USE_DEPRECATED macro is defined.

The <unwind-cxx.h> header uses std::unexpected_handler in the public
API, but since that type is the same as std::terminate_handler we can
just use that instead, to avoid warnings about it being deprecated.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/evolution.xml: Document deprecations.
	* doc/html/*: Regenerate.
	* libsupc++/exception (unexpected_handler, unexpected)
	(get_unexpected, set_unexpected): Add deprecated attribute.
	Do not define without _GLIBCXX_USE_DEPRECATED for C++17 and up.
	* libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Disable
	deprecated warnings.
	* libsupc++/eh_ptr.cc (std::rethrow_exception): Likewise.
	* libsupc++/eh_terminate.cc: Likewise.
	* libsupc++/eh_throw.cc (__cxa_init_primary_exception):
	Likewise.
	* libsupc++/unwind-cxx.h (struct __cxa_exception): Use
	terminate_handler instead of unexpected_handler.
	(struct __cxa_dependent_exception): Likewise.
	(__unexpected): Likewise.
	* testsuite/18_support/headers/exception/synopsis.cc: Add
	dg-warning for deprecated warning.
	* testsuite/18_support/exception_ptr/60612-unexpected.cc:
	Disable deprecated warnings.
	* testsuite/18_support/set_unexpected.cc: Likewise.
	* testsuite/18_support/unexpected_handler.cc: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/lambda/lambda-eh2.C: Add dg-warning for new
	deprecation warnings.
	* g++.dg/cpp0x/noexcept06.C: Likewise.
	* g++.dg/cpp0x/noexcept07.C: Likewise.
	* g++.dg/eh/forced3.C: Likewise.
	* g++.dg/eh/unexpected1.C: Likewise.
	* g++.old-deja/g++.eh/spec1.C: Likewise.
	* g++.old-deja/g++.eh/spec2.C: Likewise.
	* g++.old-deja/g++.eh/spec3.C: Likewise.
	* g++.old-deja/g++.eh/spec4.C: Likewise.
	* g++.old-deja/g++.mike/eh33.C: Likewise.
	* g++.old-deja/g++.mike/eh34.C: Likewise.
	* g++.old-deja/g++.mike/eh50.C: Likewise.
	* g++.old-deja/g++.mike/eh51.C: Likewise.
2021-11-04 20:53:29 +00:00
Jonathan Wakely
b57899f30f libstdc++: Consolidate duplicate metaprogramming utilities
Currently std::variant uses __index_of<T, Types...> to find the first
occurence of a type in a pack, and __exactly_once<T, Types...> to check
that there is no other occurrence.

We can reuse the __find_uniq_type_in_pack<T, Types...>() function for
both tasks, and remove the recursive templates used to implement
__index_of and __exactly_once.

libstdc++-v3/ChangeLog:

	* include/bits/utility.h (__find_uniq_type_in_pack): Move
	definition to here, ...
	* include/std/tuple (__find_uniq_type_in_pack): ... from here.
	* include/std/variant (__detail__variant::__index_of): Remove.
	(__detail::__variant::__exactly_once): Define using
	__find_uniq_type_in_pack instead of __index_of.
	(get<T>, get_if<T>, variant::__index_of): Likewise.
2021-11-04 18:14:50 +00:00
Jonathan Wakely
09aab7e699 libstdc++: Optimize std::tuple_element and std::tuple_size_v
This reduces the number of class template instantiations needed for code
using tuples, by reusing _Nth_type in tuple_element and specializing
tuple_size_v for tuple, pair and array (and const-qualified versions of
them).

Also define the _Nth_type primary template as a complete type (but with
no nested 'type' member).  This avoids "invalid use of incomplete type"
errors for out-of-range specializations of tuple_element. Those errors
would probably be confusing and unhelpful for users. We already have
a user-friendly static assert in tuple_element itself.

Also ensure that tuple_size_v is available whenever tuple_size is (as
proposed by LWG 3387). We already do that for tuple_element_t.

libstdc++-v3/ChangeLog:

	* include/bits/stl_pair.h (tuple_size_v): Define partial
	specializations for std::pair.
	* include/bits/utility.h (_Nth_type): Move definition here
	and define primary template.
	(tuple_size_v): Move definition here.
	* include/std/array (tuple_size_v): Define partial
	specializations for std::array.
	* include/std/tuple (tuple_size_v): Move primary template to
	<bits/utility.h>.  Define partial specializations for
	std::tuple.
	(tuple_element): Change definition to use _Nth_type.
	* include/std/variant (_Nth_type): Move to <bits/utility.h>.
	(variant_alternative, variant): Adjust qualification of
	_Nth_type.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Prune
	additional errors from _Nth_type.
2021-11-04 18:14:50 +00:00
Jonathan Wakely
a45d577b2b libstdc++: Refactor emplace-like functions in std::variant
libstdc++-v3/ChangeLog:

	* include/std/variant (__detail::__variant::__emplace): New
	function template.
	(_Copy_assign_base::operator=): Reorder conditions to match
	bulleted list of effects in the standard. Use __emplace instead
	of _M_reset followed by _Construct.
	(_Move_assign_base::operator=): Likewise.
	(__construct_by_index): Remove.
	(variant::emplace): Use __emplace instead of _M_reset followed
	by __construct_by_index.
	(variant::swap): Hoist valueless cases out of visitor. Use
	__emplace to replace _M_reset followed by _Construct.
2021-11-04 09:36:10 +00:00
Jonathan Wakely
30ab6d9e43 libstdc++: Optimize std::variant traits and improve diagnostics
By defining additional partial specializations of _Nth_type we can
reduce the number of recursive instantiations needed to get from N to 0.
We can also use _Nth_type in variant_alternative, to take advantage of
that new optimization.

By adding a static_assert to variant_alternative we get a nicer error
than 'invalid use of incomplete type'.

By defining partial specializations of std::variant_size_v for the
common case we can avoid instantiating the std::variant_size class
template.

The __tuple_count class template and __tuple_count_v variable template
can be simplified to a single variable template, __count.

By adding a deleted constructor to the _Variant_union primary template
we can (very slightly) improve diagnostics for invalid attempts to
construct a std::variant with an out-of-range index. Instead of a
confusing error about "too many initializers for ..." we get a call to a
deleted function.

By using _Nth_type instead of variant_alternative (for cv-unqualified
variant types) we avoid instantiating variant_alternative.

By adding deleted overloads of variant::emplace we get better
diagnostics for emplace<invalid-index> or emplace<invalid-type>. Instead
of getting errors explaining why each of the four overloads wasn't
valid, we just get one error about calling a deleted function.

libstdc++-v3/ChangeLog:

	* include/std/variant (_Nth_type): Define partial
	specializations to reduce number of instantiations.
	(variant_size_v): Define partial specializations to avoid
	instantiations.
	(variant_alternative): Use _Nth_type. Add static assert.
	(__tuple_count, __tuple_count_v): Replace with ...
	(__count): New variable template.
	(_Variant_union): Add deleted constructor.
	(variant::__to_type): Use _Nth_type.
	(variant::emplace): Use _Nth_type. Add deleted overloads for
	invalid types and indices.
2021-11-04 09:36:09 +00:00
Jonathan Wakely
7551a99574 libstdc++: Fix handling of const types in std::variant [PR102912]
Prior to r12-4447 (implementing P2231R1 constexpr changes) we didn't
construct the correct member of the union in __variant_construct_single,
we just plopped an object in the memory occupied by the union:

  void* __storage = std::addressof(__lhs._M_u);
  using _Type = remove_reference_t<decltype(__rhs_mem)>;
  ::new (__storage) _Type(std::forward<decltype(__rhs_mem)>(__rhs_mem));

We didn't care whether we had variant<int, const int>, we would just
place an int (or const int) into the storage, and then set the _M_index
to say which one it was.

In the new constexpr-friendly code we use std::construct_at to construct
the union object, which constructs the active member of the right type.
But now we need to know exactly the right type. We have to distinguish
between alternatives of type int and const int, and we have to be able
to find a const int (or const std::string, as in the OP) among the
alternatives. So my change from remove_reference_t<decltype(__rhs_mem)>
to remove_cvref_t<_Up> was wrong. It strips the const from const int,
and then we can't find the index of the const int alternative.

But just using remove_reference_t doesn't work either. When the copy
assignment operator of std::variant<int> uses __variant_construct_single
it passes a const int& as __rhs_mem, but if we don't strip the const
then we try to find const int among the alternatives, and *that* fails.
Similarly for the copy constructor, which also uses a const int& as the
initializer for a non-const int alternative.

The root cause of the problem is that __variant_construct_single doesn't
know the index of the type it's supposed to construct, and the new
_Variant_storage::__index_of<_Type> helper doesn't work if __rhs_mem and
the alternative being constructed have different const-qualification. We
need to replace __variant_construct_single with something that knows the
index of the alternative being constructed. All uses of that function do
actually know the index, but that context is lost by the time we call
__variant_construct_single. This patch replaces that function and
__variant_construct, inlining their effects directly into the callers.

libstdc++-v3/ChangeLog:

	PR libstdc++/102912
	* include/std/variant (_Variant_storage::__index_of): Remove.
	(__variant_construct_single): Remove.
	(__variant_construct): Remove.
	(_Copy_ctor_base::_Copy_ctor_base(const _Copy_ctor_base&)): Do
	construction directly instead of using __variant_construct.
	(_Move_ctor_base::_Move_ctor_base(_Move_ctor_base&&)): Likewise.
	(_Move_ctor_base::_M_destructive_move()): Remove.
	(_Move_ctor_base::_M_destructive_copy()): Remove.
	(_Copy_assign_base::operator=(const _Copy_assign_base&)): Do
	construction directly instead of using _M_destructive_copy.
	(variant::swap): Do construction directly instead of using
	_M_destructive_move.
	* testsuite/20_util/variant/102912.cc: New test.
2021-11-04 09:36:09 +00:00
GCC Administrator
18ae471f7b Daily bump. 2021-11-04 00:16:32 +00:00
Jonathan Wakely
1e7a269856 libstdc++: Fix regression in std::list::sort [PR66742]
The standard does not require const-correct comparisons in list::sort.

libstdc++-v3/ChangeLog:

	PR libstdc++/66742
	* include/bits/list.tcc (list::sort): Use mutable iterators for
	comparisons.
	* include/bits/stl_list.h (_Scratch_list::_Ptr_cmp): Likewise.
	* testsuite/23_containers/list/operations/66742.cc: Check
	non-const comparisons.
2021-11-03 15:15:27 +00:00
GCC Administrator
b4df2dd3f4 Daily bump. 2021-11-03 00:16:30 +00:00
Jonathan Wakely
4f032929ac libstdc++: Add some noexcept to std::valarray
libstdc++-v3/ChangeLog:

	* include/std/valarray (valarray::valarray()): Add noexcept.
	(valarray::operator[]): Likewise.
2021-11-03 00:16:01 +00:00
GCC Administrator
cf82e8d964 Daily bump. 2021-11-02 00:16:32 +00:00
Jonathan Wakely
6f34b9e4f1 libstdc++: Missing constexpr for __gnu_debug::__valid_range etc
The new 25_algorithms/move/constexpr.cc test fails in debug mode,
because the debug assertions use the non-constexpr overloads in
<debug/stl_iterator.h>.

libstdc++-v3/ChangeLog:

	* include/debug/stl_iterator.h (__valid_range): Add constexpr
	for C++20. Qualify call to avoid ADL.
	(__get_distance, __can_advance, __unsafe, __base): Likewise.
	* testsuite/25_algorithms/move/constexpr.cc: Also check with
	std::reverse_iterator arguments.
2021-11-01 21:01:31 +00:00
Jonathan Wakely
09bc98098e libstdc++: Reorder constraints on std::span::span(Range&&) constructor.
In PR libstdc++/103013 Tim Song pointed out that we could reorder the
constraints of this constructor. That's worth doing just to reduce the
work the compiler has to do during overload resolution, even if it isn't
needed to make the code in the PR work.

libstdc++-v3/ChangeLog:

	* include/std/span (span(Range&&)): Reorder constraints.
2021-11-01 21:01:31 +00:00
Jonathan Wakely
91bac9fed5 libstdc++: Fix range access for empty std::valarray [PR103022]
The std::begin and std::end overloads for std::valarray are defined in
terms of std::addressof(v[0]) which is undefined for an empty valarray.

libstdc++-v3/ChangeLog:

	PR libstdc++/103022
	* include/std/valarray (begin, end): Do not dereference an empty
	valarray. Add noexcept and [[nodiscard]].
	* testsuite/26_numerics/valarray/range_access.cc: Check empty
	valarray. Check iterator properties. Run as well as compiling.
	* testsuite/26_numerics/valarray/range_access2.cc: Likewise.
	* testsuite/26_numerics/valarray/103022.cc: New test.
2021-11-01 13:26:29 +00:00
GCC Administrator
4c61300f2b Daily bump. 2021-10-30 00:16:25 +00:00
Jonathan Wakely
d27febaf00 libstdc++: Fix typo in std::stack test
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/stack/deduction.cc: Fix typo.
2021-10-29 21:34:54 +01:00
GCC Administrator
3ff5b4edbe Daily bump. 2021-10-27 00:16:33 +00:00
Martin Sebor
9a27acc30a Make full use of context-sensitive ranges in access warnings.
gcc/ChangeLog:

	* builtins.c (check_strncat_sizes): Pass access_data ctor additional
	arguments.
	(expand_builtin_memcmp): Move code to gimple-ssa-warn-access.cc.
	(expand_builtin_fork_or_exec): Same.
	* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref): Pass
	compute_objsize additional arguments.
	(inbounds_memaccess_p): Same.
	(array_bounds_checker::check_array_bounds): Add an assert.  Stash
	statement in a member.
	(check_array_bounds_dom_walker::before_dom_children): Same.
	* gimple-array-bounds.h (array_bounds_checker::m_stmt): New member.
	* gimple-ssa-sprintf.c (get_destination_size): Add an argument.
	(handle_printf_call): Pass a new argument.
	* gimple-ssa-warn-access.cc (get_size_range): Add an argument.
	(check_access): Add an argument and pass it along to callees.
	(check_read_access): Make a member function.
	(pass_waccess::check_strcat): Pass access_data ctor additional
	arguments.
	(pass_waccess::check_strncat): Same.
	(pass_waccess::check_stxcpy): Same.
	(pass_waccess::check_stxncpy): Same.
	(pass_waccess::check_strncmp): Same.
	(pass_waccess::check_read_access): Same.
	(pass_waccess::check_builtin): Same.
	(pass_waccess::maybe_check_access_sizes): Same.
	(pass_waccess::maybe_check_dealloc_call): Same.
	* gimple-ssa-warn-access.h (check_read_access): Declare a new
	member function.
	* pointer-query.cc (compute_objsize_r): Add an argument.
	(gimple_call_return_array): Same.
	(gimple_call_alloc_size): Same.
	(access_ref::access_ref): Same.
	(access_ref::get_ref): Same.
	(pointer_query::get_ref): Same.
	(handle_min_max_size): Pass an arguments to callees.
	(handle_array_ref): Add an argument.
	(handle_mem_ref): Same.
	(compute_objsize): Same.
	* pointer-query.h (struct access_ref): Adjust signatures.
	(struct access_data): Same.
	(gimple_call_alloc_size): Add an argument.
	(gimple_parm_array_size): Same.
	(compute_objsize): Same.
	* tree-ssa-strlen.c (strlen_pass::adjust_last_stmt): Pass an additional
	argument to compute_objsize.
	(strlen_pass::maybe_warn_overflow): Same.
	(maybe_diag_stxncpy_trunc): Same.

gcc/testsuite/ChangeLog:

	* gcc.dg/Wstringop-overflow-22.c: Correct typos.
	* gcc.dg/Wstringop-overflow-81.c: New test.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/capacity/1.cc: Also suppress
	-Wstringop-overread.
	* testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc: Same.
2021-10-26 16:53:23 -06:00
Rainer Orth
931f1e377a libstdc++: Fix 28_regex/basic_regex/84110.cc on Solaris
28_regex/basic_regex/84110.cc currently FAILs on Solaris:

FAIL: 28_regex/basic_regex/84110.cc (test for excess errors)
UNRESOLVED: 28_regex/basic_regex/84110.cc compilation failed to produce executable

Excess errors:
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/28_regex/basic_regex/84110.cc:14: error: reference to 'extended' is ambiguous

The issue is seen in the full output:

/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/28_regex/basic_regex/84110.cc: In function ‘void test01()’:
/vol/gcc/src/hg/master/local/libstdc++-v3/testsuite/28_regex/basic_regex/84110.cc:14: error: reference to ‘extended’ is ambiguous
In file included from /var/gcc/regression/master/11.4-gcc-gas/build/gcc/include-fixed/math.h:391,
                 from /var/gcc/regression/master/11.4-gcc-gas/build/i386-pc-solaris2.11/libstdc++-v3/include/cmath:45,
                 from /vol/gcc/src/hg/master/local/libstdc++-v3/include/precompiled/stdc++.h:41:
/usr/include/floatingpoint.h:73: note: candidates are: ‘typedef unsigned int extended [3]’

Fixed by disambiguating extended.  Tested on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.


2021-10-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libstdc++-v3:
	* testsuite/28_regex/basic_regex/84110.cc (test01)
	[__cpp_exceptions]: Disambiguate extended.
2021-10-26 14:07:57 +02:00
Rainer Orth
88037d82d7 libstdc++: Fix 17_intro/names.cc on Solaris
17_intro/names.cc and experimental/names.cc currently FAIL on Solaris

FAIL: 17_intro/names.cc (test for excess errors)
FAIL: experimental/names.cc (test for excess errors)

Excess errors:
/usr/include/sys/timespec_util.h:22: error: expected ')' before ';' token
/usr/include/stdlib.h:157: error: expected unqualified-id before '[' token
/usr/include/stdlib.h:157: error: expected ')' before '[' token

<sys/timespec_util.h> has

extern int timespeccompare(const struct timespec *l, const struct timespec *r);

while <stdlib.h> has

typedef struct drand48_data {
        unsigned int _initialised;
        unsigned short int x[3];
        unsigned short int a[3];
        unsigned int c;
        unsigned short lastx[3];
} drand48_data;

both of which are broken by defining r resp. x to ( in the testcase.

Fixed by undoing the defines.  Tested on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.


2021-10-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libstdc++-v3:
	* testsuite/17_intro/names.cc [__sun__] (r, x): Undef.
2021-10-26 14:00:18 +02:00
GCC Administrator
c2bd5d8a30 Daily bump. 2021-10-23 00:16:26 +00:00
Jonathan Wakely
0c1f737a48 libstdc++: Constrain std::make_any [PR102894]
std::make_any should be constrained so it can only be called if the
construction of the return value would be valid.

libstdc++-v3/ChangeLog:

	PR libstdc++/102894
	* include/std/any (make_any): Add SFINAE constraint.
	* testsuite/20_util/any/102894.cc: New test.
2021-10-22 23:09:54 +01:00
GCC Administrator
ae5c540662 Daily bump. 2021-10-22 00:16:31 +00:00
Jonathan Wakely
394f60e6ed libstdc++: Improve generated man pages for libstdc++
The man pages generated by Doxygen show internal header files, not the
standard headers that users actually care about. The run_doxygen script
uses the doc/doxygen/stdheader.cc program to address that, but it
doesn't work. It only tries to fix headers with underscores in the
names, which doesn't work for <bits/align.h> or <bits/fsteam.tcc>.  It
isn't prepared for the strings like "bits/stl_set\&.h" that are produced
by Doxygen. It doesn't know about many headers that have been added
since it was written. And the run_doxygen script fails to use its output
correctly to modify the man pages. Additionally, run_doxygen doesn't
know about new nested namespaces like std::filesystem and std::ranges.

This change rewrites the stdheader.cc program to do a better job of
finding the right header. The run_doxygen script now uses the just-built
compiler to build stdheader.cc and actually uses its output. And the
script now knows about other nested namespaces.

The stdheader.cc program might be unnecessary if we consistently used
@headername tags in the Doxygen comments, but we don't (and probably
never will).

A problem that remains after this change is that all the free function
defined in namespace std get dumped into a single man page for std(3),
without detailed descriptions. We don't even install that std(3) page,
but remove it before installation. That means only classes are
documented in man pages (including many internal ones that should not be
publicly documented such as _Deque_base and _Tuple_impl).

libstdc++-v3/ChangeLog:

	* doc/doxygen/stdheader.cc: Refactor. Use C++23. Add new
	headers.
	* scripts/run_doxygen: Fix post-processing of #include
	directives in man pages. Use new xg++ to compile helper program.
2021-10-21 22:24:57 +01:00
Jonathan Wakely
5a5d7c2c80 libstdc++: Add Doxygen comments to contents of <functional>
libstdc++-v3/ChangeLog:

	* include/bits/mofunc_impl.h: Add doxygen comments.
	* include/std/functional: Likewise.
2021-10-21 22:24:53 +01:00
Jonathan Wakely
6667d5feb9 libstdc++: Suppress Doxygen docs for more implementation details
libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h: Suppress doxygen documentation.
	* include/bits/allocated_ptr.h: Likewise.
	* include/bits/enable_special_members.h: Likewise.
	* include/bits/hashtable.h: Likewise.
	* include/bits/hashtable_policy.h: Likewise.
	* include/bits/uses_allocator.h: Likewise.
	* include/bits/node_handle.h: Document node handles and suppress
	documentation for protected members.
	* include/std/any: Suppress documentation for implementation
	details.
2021-10-21 22:23:00 +01:00
Patrick Palka
5f7976f65b libstdc++: missing constexpr for __[nm]iter_base [PR102358]
PR libstdc++/102358

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (__niter_base): Make constexpr
	for C++20.
	(__miter_base): Likewise.
	* testsuite/25_algorithms/move/constexpr.cc: New test.
2021-10-21 12:13:35 -04:00
Patrick Palka
48154969d4 libstdc++: Implement P2432R1 changes for views::istream
libstdc++-v3/ChangeLog:

	* include/std/ranges (istream_view): Replace this function
	template with an alias template as per P2432R1.
	(wistream_view): Define as per P2432R1.
	(views::_Istream, views::istream): Likewise.
	* testsuite/std/ranges/istream_view.cc (test07): New test.
2021-10-21 11:55:19 -04:00
Patrick Palka
9626e44713 libstdc++: Implement P1739R4 changes to views::take/drop/counted
This implements P1739R4 along with the resolution for LWG 3407 which
corrects the paper's wording.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (views::_Drop): Forward declare.
	(subrange): Befriend views::_Drop.
	(subrange::_S_store_size): Declare constexpr instead of just
	const, remove obsolete comment.
	* include/std/ranges (views::__detail::__is_empty_view): Define.
	(views::__detail::__is_basic_string_view): Likewise.
	(views::__detail::__is_subrange): Likewise.
	(views::__detail::__is_iota_view): Likewise.
	(views::__detail::__can_take_view): Rename template parm _Tp to _Dp.
	(views::_Take): Rename template parm _Tp to _Dp, make it non-deducible
	and fix it to range_difference_t<_Range>.  Implement P1739R4 and
	LWG 3407 changes.
	(views::__detail::__can_drop_view): Rename template parm _Tp to _Dp.
	(views::_Drop): As with views::_Take.
	(views::_Counted): Implement P1739R4 changes.
	* include/std/span (__detail::__is_std_span): Rename to ...
	(__detail::__is_span): ... this and turn it into a variable
	template.
	(__detail::__is_std_array): Turn it into a variable template.
	(span::span): Adjust uses of __is_std_span and __is_std_array
	accordingly.
	* testsuite/std/ranges/adaptors/p1739.cc: New test.
2021-10-21 11:55:16 -04:00
Patrick Palka
1556e447c0 libstdc++: Implement LWG 3595 changes to common_iterator
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (common_iterator::__arrow_proxy):
	Make fully constexpr as per LWG 3595.
	(common_iterator::__postfix_proxy): Likewise.
2021-10-20 21:43:42 -04:00
Patrick Palka
2d3ac60390 libstdc++: Implement LWG 3590-3592 changes to split_view/lazy_split_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (lazy_split_view::base): Add forward_range
	constraint as per LWG 3591.
	(lazy_split_view::begin, lazy_split_view::end): Also check
	simpleness of _Pattern as per LWG 3592.
	(split_view::base): Relax copyable constraint as per LWG 3590.
2021-10-20 21:34:23 -04:00
Patrick Palka
6667274b05 libstdc++: Implement LWG 3535 changes to ranges::join_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view::__iter_cat::_S_iter_cat): Adjust
	criteria for returning bidirectional_iterator_tag as per LWG 3535.
	(join_view::_Iterator::_S_iter_concept): Likewise.
2021-10-20 21:34:21 -04:00
Patrick Palka
a2c2dcc6ca libstdc++: Implement LWG 3481 change to ranges::viewable_range
libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (viewable_range): Adjust as per
	LWG 3481.
	* testsuite/std/ranges/adaptors/all.cc (test07): New test.
2021-10-20 21:34:18 -04:00
Jonathan Wakely
0fac85a24f libstdc++: Remove constraints from std::optional monadic ops [PR102863]
The constraints on transform and and_then can cause errors when checking
satisfaction. The constraints that were present in R6 of the paper were
moved for he final F8 revision, and so should have been included in the
implementation.

libstdc++-v3/ChangeLog:

	PR libstdc++/102863
	* include/std/optional (optional::and_then, optional::transform):
	Remove requires-clause.
	* testsuite/20_util/optional/monadic/and_then.cc: Check
	overload resolution doesn't cause errors.
	* testsuite/20_util/optional/monadic/transform.cc: Likewise.
2021-10-21 01:23:22 +01:00
GCC Administrator
674dda6be0 Daily bump. 2021-10-21 00:16:29 +00:00
Jonathan Wakely
4ba4b05315 libstdc++: Add missing test for std::optional::transform(F&&)
The test_copy_elision() function was supposed to ensure that the result
is constructed directly in the std::optional, without early temporary
materialization. But I forgot to write the test.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/optional/monadic/transform.cc: Check that
	an rvalue result is not materialized too soon.
2021-10-20 20:20:18 +01:00
GCC Administrator
19472fc3fc Daily bump. 2021-10-20 00:16:43 +00:00
Patrick Palka
5566f3c6b4 libstdc++: Implement LWG 3580 change to ranges::iota_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (iota_view::_Iterator::operator+): Adjust
	definition as per LWG 3580.
	(iota_view::_Iterator::operator-): Likewise.
2021-10-19 18:07:19 -04:00
Patrick Palka
bed1892f5b libstdc++: Implement LWG 3568 change to ranges::basic_istream_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (basic_istream_view::_M_object): Value
	initialize as per LWG 3568.
2021-10-19 18:07:16 -04:00
Patrick Palka
98af6b86bc libstdc++: Implement LWG 3470 change to ranges::subrange
libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h
	(__detail::__uses_nonqualification_pointer_conversion): Define
	and use it ...
	(__detail::__convertible_to_nonslicing): ... here, as per LWG 3470.
	* testsuite/std/ranges/subrange/1.cc: New test.
2021-10-19 18:07:05 -04:00
Patrick Palka
861440a77b libstdc++: Implement LWG 3523 changes to ranges::iota_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (iota_view::_Iterator): Befriend iota_view.
	(iota_view::_Sentinel): Likewise.
	(iota_view::iota_view): Add three overloads, each taking an
	iterator/sentinel pair as per LWG 3523.
	* testsuite/std/ranges/iota/iota_view.cc (test06): New test.
2021-10-19 17:54:24 -04:00
Patrick Palka
53b1c382d5 libstdc++: Implement LWG 3549 changes to ranges::enable_view
This patch also reverts r11-3504 since that workaround is now obsolete
after this resolution.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (view_interface): Forward declare.
	(__detail::__is_derived_from_view_interface_fn): Declare.
	(__detail::__is_derived_from_view_interface): Define as per LWG 3549.
	(enable_view): Adjust as per LWG 3549.
	* include/bits/ranges_util.h (view_interface): Don't derive from
	view_base.
	* include/std/ranges (filter_view): Revert r11-3504 change.
	(transform_view): Likewise.
	(take_view): Likewise.
	(take_while_view): Likewise.
	(drop_view): Likewise.
	(drop_while_view): Likewise.
	(join_view): Likewise.
	(lazy_split_view): Likewise.
	(split_view): Likewise.
	(reverse_view): Likewise.
	* testsuite/std/ranges/adaptors/sizeof.cc: Update expected sizes.
	* testsuite/std/ranges/view.cc (test_view::test_view): Remove
	this default ctor since views no longer need to be default initable.
	(test01): New test.
2021-10-19 17:50:56 -04:00
Jonathan Wakely
58f339fc5e libstdc++: Implement std::random_device::entropy() for other sources
Currently this function only returns a non-zero value for /dev/random
and /dev/urandom. When a hardware instruction such as RDRAND is in use
it should (in theory) be perfectly random and produce 32 bits of entropy
in each 32-bit result. Add a helper function to identify the source of
randomness from the _M_func and _M_file data members, and return a
suitable value when RDRAND or RDSEED is being used.

libstdc++-v3/ChangeLog:

	* src/c++11/random.cc (which_source): New helper function.
	(random_device::_M_getentropy()): Use which_source and return
	suitable values for sources other than device files.
	* testsuite/26_numerics/random/random_device/entropy.cc: New test.
2021-10-19 17:27:06 +01:00
Jonathan Wakely
04d392e843 libstdc++: Fix doxygen generation to work with relative paths
In r12-826 I tried to remove some redundant steps from the doxygen
build, but they are needed when configure is run as a relative path. The
use of pwd is to resolve the relative path to an absolute one.

libstdc++-v3/ChangeLog:

	* doc/Makefile.am (stamp-html-doxygen, stamp-html-doxygen)
	(stamp-latex-doxygen, stamp-man-doxygen): Fix recipes for
	relative ${top_srcdir}.
	* doc/Makefile.in: Regenerate.
2021-10-19 16:07:41 +01:00
Jonathan Wakely
5a8832b165 libstdc++: Change std::variant union member to empty struct
This more clearly expresses the intent (a completely unused, trivial
type) than using char. It's also consistent with the unions in
std::optional.

libstdc++-v3/ChangeLog:

	* include/std/variant (_Uninitialized): Use an empty struct
	for the unused union member, instead of char.
2021-10-19 15:01:16 +01:00
Jonathan Wakely
c4ecb11e4f libstdc++: Fix std::stack deduction guide
libstdc++-v3/ChangeLog:

	* include/bits/stl_stack.h (stack(Iterator, Iterator)): Remove
	non-deducible template parameter from deduction guide.
	* testsuite/23_containers/stack/deduction.cc: Check new C++23
	deduction guides.
2021-10-19 15:01:16 +01:00
Jonathan Wakely
82b2e4f8cf libstdc++: Implement monadic operations for std::optional (P0798R8)
Another new addition to the C++23 working draft.

The new member functions of std::optional are only defined for C++23,
but the new members of _Optional_payload_base are defined for C++20 so
that they can be used in non-propagating-cache in <ranges>. The
_Optional_payload_base::_M_construct member can also be used in
non-propagating-cache now, because it's constexpr since r12-4389.

There will be an LWG issue about the feature test macro, suggesting that
we should just bump the value of __cpp_lib_optional instead. I haven't
done that here, but it can be changed once consensus is reached on the
change.

libstdc++-v3/ChangeLog:

	* include/std/optional (_Optional_payload_base::_Storage): Add
	constructor taking a callable function to invoke.
	(_Optional_payload_base::_M_apply): New function.
	(__cpp_lib_monadic_optional): Define for C++23.
	(optional::and_then, optional::transform, optional::or_else):
	Define for C++23.
	* include/std/ranges (__detail::__cached): Remove.
	(__detail::__non_propagating_cache): Remove use of __cached for
	contained value. Use _Optional_payload_base::_M_construct and
	_Optional_payload_base::_M_apply to set the contained value.
	* include/std/version (__cpp_lib_monadic_optional): Define.
	* testsuite/20_util/optional/monadic/and_then.cc: New test.
	* testsuite/20_util/optional/monadic/or_else.cc: New test.
	* testsuite/20_util/optional/monadic/or_else_neg.cc: New test.
	* testsuite/20_util/optional/monadic/transform.cc: New test.
	* testsuite/20_util/optional/monadic/version.cc: New test.
2021-10-19 15:01:16 +01:00
Jonathan Wakely
9890b12c72 libstdc++: Fix mem-initializer in std::move_only_function [PR102825]
libstdc++-v3/ChangeLog:

	PR libstdc++/102825
	* include/bits/mofunc_impl.h (move_only_function): Remove
	invalid base initializer.
	* testsuite/20_util/move_only_function/cons.cc: Instantiate
	constructors to check bodies.
2021-10-19 11:50:46 +01:00
GCC Administrator
93d183a5ff Daily bump. 2021-10-16 00:16:27 +00:00
Jonathan Wakely
e547d1341b libstdc++: Fix error in filesystem::path with Clang
THis fixes teh following error seen with Clang:

error: function '_S_convert<std::basic_string_view<char8_t>>' with deduced
return type cannot be used before it is defined
          return string_type(_S_convert(std::u8string_view(__str)));
                             ^

libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (path::_S_convert(T)): Avoid recursive
	call to function with deduced return type.
2021-10-16 00:44:28 +01:00
Jonathan Wakely
929abc7fe3 libstdc++: Define std::basic_string::resize_and_overwrite for C++23 (P1072R10)
A recently approved change for the C++23 working draft.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (__cpp_lib_string_resize_and_overwrite):
	Define for C++23.
	(basic_string::resize_and_overwrite): Declare.
	* include/bits/basic_string.tcc (basic_string::resize_and_overwrite):
	Define.
	* include/std/version (__cpp_lib_resize_and_overwrite): Define
	for C++23.
	* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
	New test.
2021-10-16 00:44:16 +01:00
Jonathan Wakely
2c564e813c libstdc++: Make non-propagating-cache fully constexpr [PR101263]
libstdc++-v3/ChangeLog:

	PR libstdc++/101263
	* include/std/ranges (__cached): New wrapper struct.
	(__non_propagating_cache): Use __cached for contained value.
	(__non_propagating_cache::_M_emplace_deref): Add constexpr. Use
	std::construct_at instead of placement new.
	* testsuite/std/ranges/adaptors/join.cc: Check constexpr works.
2021-10-15 18:26:53 +01:00
Jonathan Wakely
ad820b0bb5 libstdc++: Add missing constexpr to std::variant (P2231R1)
This implements the changes in P2231R1 which make std::variant fully
constexpr in C++20.

We need to replace placement new with std::construct_at, but that isn't
defined for C++17. Use std::_Construct instead, which forwards to
std::construct_at in C++20 mode (since the related changes to make
std::optional fully constexpr, in r12-4389).

We also need to replace the untyped char buffer in _Uninitialized with a
union, which can be accessed in constexpr functions. But the union needs
to have a non-trivial destructor if its variant type is non-trivial,
which means that the _Variadic_union also needs a non-trivial
destructor. This adds a constrained partial specialization of
_Variadic_union for the C++20-only case where a non-trivial destructor
is needed.

We can't use concepts to constrain the specialization (or the primary
template's destructor) in C++17, so retain the untyped char buffer
solution for C++17 mode.

libstdc++-v3/ChangeLog:

	* include/std/variant (__cpp_lib_variant): Update value for
	C++20.
	(__variant_cast, __variant_construct): Add constexpr for C++20.
	(__variant_construct_single, __construct_by_index) Likewise. Use
	std::_Construct instead of placement new.
	(_Uninitialized<T, false>) [__cplusplus >= 202002]: Replace
	buffer with a union and define a destructor.
	(_Variadic_union) [__cplusplus >= 202002]: Add a specialization
	for non-trivial destruction.
	(_Variant_storage::__index_of): New helper variable template.
	(_Variant_storage::~_Variant_storage()): Add constexpr.
	(_Variant_storage::_M_reset()): Likewise.
	(_Copy_ctor_base, _Move_ctor_base): Likewise.
	(_Copy_assign_base, _Move_assign_base): Likewise.
	(variant, swap): Likewise.
	* include/std/version (__cpp_lib_variant): Update value for
	C++20.
	* testsuite/20_util/optional/version.cc: Check for exact value
	in C++17.
	* testsuite/20_util/variant/87619.cc: Increase timeout for
	C++20 mode.
	* testsuite/20_util/variant/constexpr.cc: New test.
	* testsuite/20_util/variant/version.cc: New test.
2021-10-15 18:26:53 +01:00
Jonathan Wakely
e27771e5dc libstdc++: Remove try/catch overhead in std::variant::emplace
The __variant_construct_by_index helper function sets the new index
before constructing the new object. This means that if the construction
throws then the exception needs to be caught, so the index can be reset
to variant_npos, and then the exception rethrown. This means callers are
responsible for restoring the variant's invariants and they need the
overhead of a catch handler and a rethrow.

If we don't set the index until after construction completes then the
invariant is never broken, and callers can ignore the exception and let
it propagate. The callers all call _M_reset() first, which sets index to
variant_npos as required while the variant is valueless.

We need to be slightly careful here, because changing the order of
operations in __variant_construct_by_index and removing the try-block
from variant::emplace<I> changes an implicit ABI contract between those
two functions. If the linker were to create an executable containing an
instantiation of the old __variant_construct_by_index and an
instantiation of the new variant::emplace<I> code then we would have a
combination that breaks the invariant and doesn't have the exception
handling to restore it. To avoid this problem, we can rename the
__variant_construct_by_index function so that the new emplace<I> code
calls a new symbol, and is unaffected by the behaviour of the old
symbol.

libstdc++-v3/ChangeLog:

	* include/std/variant (__detail::__variant::__get_storage):
	Remove unused function.
	(__variant_construct_by_index): Set index after construction is
	complete. Rename to ...
	(__detail::__variant::__construct_by_index): ... this.
	(variant): Use new name for __variant_construct_by_index friend
	declaration. Remove __get_storage friend declaration.
	(variant::emplace): Use new name and remove try-blocks.
2021-10-15 18:26:53 +01:00
Jonathan Wakely
1ba7adabf2 libstdc++: Remove unused functions in std::variant implementation
These functions aren't used, and accessing the storage as a void* isn't
compatible with C++20 constexpr requirements anyway, so we're unlikely
to ever start using them in future.

libstdc++-v3/ChangeLog:

	* include/std/variant (_Variant_storage::_M_storage()): Remove.
	(__detail::__variant::__get_storage): Remove.
	(variant): Remove friend declaration of __get_storage.
2021-10-15 18:26:52 +01:00
Jason Merrill
1595fe44e1 c++: instantiate less for constant folding
I've been experimenting with a change to make all inline functions
implicitly constexpr; this revealed that we are instantiating too
aggressively for speculative constant evaluation, leading to ordering
difficulties with e.g. is_a_helper<cgraph_node*>::test.  This patch tries to
avoid such instantiation until we actually need the function definition to
determine whether a call is constant, by limiting the initial instantiation
of all used functions to manifestly-constant-evaluated expressions, and
checking whether the function arguments are constant before instantiating
the function.

This change resulted in a change in the diagnostics for a few library tests
due to instantiating the function with the static_assert later (during
constant evaluation) than we did before (during instantiation of the
intermediate function).

gcc/cp/ChangeLog:

	* constexpr.c (cxx_bind_parameters_in_call): Replace
	new_call parameter with fun.
	(cxx_eval_call_expression): Call it before instantiation.
	(cxx_eval_outermost_constant_expr): Only instantiate fns
	when manifestly_const_eval.
	* typeck2.c (check_narrowing): This context is manifestly
	constant-evaluated.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/integer_comparisons/greater_equal_neg.cc:
	* testsuite/20_util/integer_comparisons/greater_neg.cc:
	* testsuite/20_util/integer_comparisons/less_equal_neg.cc:
	Adjust expected message.
	* testsuite/lib/prune.exp: Prune 'in constexpr expansion'.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/vla22.C: Don't expect a narrowing error.
	* g++.dg/cpp0x/constexpr-inst1.C: New test.
2021-10-14 21:40:11 -04:00
GCC Administrator
5d5885c99c Daily bump. 2021-10-15 00:17:02 +00:00
Jonathan Wakely
4f87d4c5ae libstdc++: Simplify variant access functions
libstdc++-v3/ChangeLog:

	* include/std/variant (__variant::__get(in_place_index_t<N>, U&&)):
	Rename to __get_n and remove first argument. Replace pair of
	overloads with a single function using 'if constexpr'.
	(__variant::__get(Variant&&)): Adjust to use __get_n.
2021-10-14 22:19:38 +01:00
Jonathan Wakely
373acac1c8 libstdc++: Make filesystem::path(path&&) always noexcept
Since r12-4065 std::basic_string is always nothrow-move-constructible,
so filesystem::path is too.

That also means that path::_S_convert(T) is noexcept when returning its
argument, because T is either a basci_string or basic_string_view, and
will be moved into the return value.

libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (path(path&&)): Make unconditionally
	noexcept.
	(path::_S_convert(T)): Add condtional noexcept.
2021-10-14 22:19:38 +01:00
Jonathan Wakely
5e3f888389 libstdc++: Fix brainwrong in path::_S_convert(T) [PR102743]
This function was supposed to check whether the parameter's value type
is the same as path::value_type, and therefore needs no conversion.
Instead it checks whether the parameter is the same as its own value
type, which is never true. This means we incorrectly return a string
view for the case where T is path::string_type, instead of just
returning the string itself. The only place that happens is
path::_S_convert_loc for Windows, where we call _S_convert with a
std::wstring rvalue.

This fixes the condition in _S_convert(T).

libstdc++-v3/ChangeLog:

	PR libstdc++/102743
	* include/bits/fs_path.h (path::_S_convert(T)): Fix condition
	for returning the same string unchanged.
2021-10-14 15:12:34 +01:00
Jonathan Wakely
3d95867ce6 libstdc++: Use more descriptive feature test macro
The out-of-class definitions of the static constants are redundant if
the __cpp_inline_variables feature is supported, so use that macro to
decide whether to define them or not.

libstdc++-v3/ChangeLog:

	* include/bits/regex.h: Check __cpp_inline_variables instead of
	__cplusplus.
2021-10-14 15:12:33 +01:00
Jonathan Wakely
6e3bfd60e8 libstdc++: Fix test for feature test macro
libstdc++-v3/ChangeLog:

	* testsuite/20_util/is_layout_compatible/version.cc: Check
	correct macro.
2021-10-14 09:08:01 +01:00
Jonathan Wakely
476f305b6c libstdc++: Add missing constexpr to std::optional (P2231R1)
This implements the changes in P2231R1 which make std::optional fully
constexpr in C++20.

libstdc++-v3/ChangeLog:

	* include/bits/stl_construct.h (_Construct): Use
	std::construct_at when constant evaluated.
	* include/std/optional (_Storage, _Optional_payload, optional):
	Add constexpr as specified by P2231R1.
	* include/std/version (__cpp_lib_optional): Update value for
	C++20.
	* testsuite/20_util/optional/requirements.cc: Check feature test
	macro.
	* testsuite/20_util/optional/constexpr/assign.cc: New test.
	* testsuite/20_util/optional/constexpr/cons/conv.cc: New test.
	* testsuite/20_util/optional/constexpr/modifiers.cc: New test.
	* testsuite/20_util/optional/constexpr/swap.cc: New test.
	* testsuite/20_util/optional/version.cc: New test.
2021-10-14 09:08:01 +01:00
GCC Administrator
9eb28a0f19 Daily bump. 2021-10-14 00:16:31 +00:00
Jonathan Wakely
f874a13ca3 libstdc++: Fix regression in memory use when constructing paths
The changes in r12-4381 were intended to reduce memory usage, but
replacing the __contiguous constant in __string_from_range with the new
__is_contiguous variable template caused a regression. The old code
checked is_pointer_v<decltype(std::__niter_base(__first))> but he new
code just checks is_pointer_v<_InputIterator>. This means that we no
longer recognise basic_string::iterator and vector::iterator as
contiguous, and so return a temporary basic_string instead of a
basic_string_view. This only affects C++17 mode, because the
std::contiguous_iterator concept is used in C++20 which gives the right
answer for __normal_iterator (and more types as well).

The fix is to specialize the new __is_contiguous variable template so it
is true for __normal_iterator<T*, C> specializations. The new partial
specializations are defined for C++20 too, because it should be cheaper
to match the partial specialization than to check whether the
std::contiguous_iterator concept is satisfied.

libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (__detail::__is_contiguous): Add
	partial specializations for pointers and __normal_iterator.
2021-10-13 22:35:32 +01:00
Jonathan Wakely
ce55693604 libstdc++: Rename files with the wrong extensions
libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/path/construct/102592.C: Moved to...
	* testsuite/27_io/filesystem/path/construct/102592.cc: ...here.
	* testsuite/28_regex/match_results/102667.C: Moved to...
	* testsuite/28_regex/match_results/102667.cc: ...here.
2021-10-13 22:35:14 +01:00
Jonathan Wakely
b83b810ac4 libstdc++: Refactor filesystem::path encoding conversions
Adjust the __detail::__effective_range overloads so they always return a
string or string view using std::char_traits, because we don't care
about the traits of an incoming string.

Use std::contiguous_iterator in the __effective_range(const Source&)
overload, to allow returning a basic_string_view in more cases. For the
non-contiguous casecl in both __effective_range and __string_from_range,
return a std::string instead of std::u8string when the value type of the
range is char8_t.  These changes avoid unnecessary basic_string
temporaries.

Also simplify __string_from_range(Iter, Iter) to not need
std::__to_address for the contiguous case.

Combine the _S_convert(string_type) and _S_convert(const T&) overloads
into a single _S_convert(T) function which also avoids the dangling
view problem of PR 102592 (should that recur somehow).

libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (__detail::__is_contiguous): New
	variable template to identify contiguous iterators.
	(__detail::__unified_char8_t): New alias template to decide when
	to treat char8_t as char without encoding conversion.
	(__detail::__effective_range(const basic_string<C,T>&)): Use
	std::char_traits<C> for returned string view.
	(__detail::__effective_range(const basic_string_view<C,T>&)):
	Likewise.
	(__detail::__effective_range(const Source&)): Use
	__is_contiguous to detect mode cases of contiguous iterators.
	Use __unified_char8_t to return a std::string instead of
	std::u8string.
2021-10-13 20:36:51 +01:00
Jonathan Wakely
85b24e32dc libstdc++: Fix dangling string_view in filesystem::path [PR102592]
When creating a path from a pair of non-contiguous iterators we pass the
iterators to _S_convert(Iter, Iter). That function passes the iterators
to __string_from_range to get a contiguous sequence of characters, and
then calls _S_convert(const C*, const C*) to perform the encoding
conversions. If the value type, C, is char8_t, then no conversion is
needed and the _S_convert<char8_t>(const char8_t*, const char8_t*)
specialization casts the pointer to const char* and returns a
std::string_view that refs to the char8_t sequence. However, that
sequence is owned by the std::u8string rvalue returned by
__string_from_range, which goes out of scope when _S_convert(Iter, Iter)
returns. That means the std::string_view is dangling and we get
undefined behaviour when parsing it as a path.

The same problem does not exist for the path members taking a "Source"
argument, because those functions all convert a non-contiguous range
into a basic_string<C> immediately, using __effective_range(__source).
That means that the rvalue string returned by that function is still in
scope for the full expression, so the string_view does not dangle.

The solution for the buggy functions is to do the same thing, and call
__string_from_range immediately, so that the returned rvalue is still in
scope for the lifetime of the string_view returned by _S_convert. To
avoid reintroducing the same problem, remove the _S_convert(Iter, Iter)
overload that calls __string_from_range and returns a dangling view.

libstdc++-v3/ChangeLog:

	PR libstdc++/102592
	* include/bits/fs_path.h (path::path(Iter, Iter, format))
	(path::append(Iter, Iter), path::concat(Iter, Iter)): Call
	__string_from_range directly, instead of two-argument overload
	of _S_convert.
	(path::_S_convert(Iter, Iter)): Remove.
	* testsuite/27_io/filesystem/path/construct/102592.C: New test.
2021-10-13 20:36:51 +01:00
Jonathan Wakely
c1b6c360fc libstdc++: Ensure language linkage of std::__terminate()
This is needed because people still find it necessary to do:

  extern "C" {
  #include <stdlib.h>
  }

libstdc++-v3/ChangeLog:

	* include/bits/c++config (__terminate): Add extern "C++".
2021-10-13 10:42:45 +01:00
GCC Administrator
52055987fb Daily bump. 2021-10-13 00:16:22 +00:00
Jonathan Wakely
727137d6ca libstdc++: Fix test that fails for C++20
Also restore the test for 'a < a' that was removed by r12-2537 because
it is ill-formed. We still want to test operator< for tuple, we just
need to not use std::nullptr_t in that tuple type.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/tuple/comparison_operators/overloaded.cc:
	Restore test for operator<.
	* testsuite/20_util/tuple/comparison_operators/overloaded2.cc:
	Adjust expected errors for C++20.
2021-10-12 16:05:15 +01:00
Jonathan Wakely
7481021364 libstdc++: Fix move construction of std::tuple with array elements [PR101960]
The r12-3022 commit only fixed the case where an array is the last
element of the tuple. This fixes the other cases too. We can just define
the move constructor as defaulted, which does the right thing. Changing
the move constructor to be trivial would be an ABI break, but since the
last base class still has a non-trivial move constructor, defining the
derived ones as defaulted doesn't change anything.

libstdc++-v3/ChangeLog:

	PR libstdc++/101960
	* include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Define as
	defauled.
	* testsuite/20_util/tuple/cons/101960.cc: Check tuples with
	array elements before the last element.
2021-10-12 16:05:15 +01:00
Jonathan Wakely
d9dfd7ad3e libstdc++: Improve diagnostics for misuses of output iterators
This adds deleted overloads so that the errors for invalid uses of
std::advance and std::distance are easier to understand (see for example
PR 102181).

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator_base_funcs.h (__advance): Add
	deleted overload to improve diagnostics.
	(__distance): Likewise.
2021-10-12 16:05:15 +01:00
GCC Administrator
732d763847 Daily bump. 2021-10-12 00:17:02 +00:00
Jonathan Wakely
250ddf4c0b libstdc++: Add wrapper for internal uses of std::terminate
This adds an inline wrapper for std::terminate that doesn't add the
declaration of std::terminate to namespace std. This allows the
library to terminate without including all of <exception>.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_timed_wait.h: Remove unused header.
	* include/bits/c++config (std:__terminate): Define.
	* include/bits/semaphore_base.h: Remove <exception> and use
	__terminate instead of terminate.
	* include/bits/std_thread.h: Likewise.
	* libsupc++/eh_terminate.cc (std::terminate): Use qualified-id
	to call __cxxabiv1::__terminate.
2021-10-11 20:35:51 +01:00
Jonathan Wakely
247bac507e libstdc++: Simplify std::basic_regex::assign
We know that if __is_contiguous_iterator is true then we have a pointer
or a __normal_iterator that wraps a pointer, so we don't need to use
std::__to_address.

libstdc++-v3/ChangeLog:

	* include/bits/regex.h (basic_regex::assign(Iter, Iter)): Avoid
	std::__to_address by using poitner directly or using base()
	member of __normal_iterator.
2021-10-11 20:35:45 +01:00
Jonathan Wakely
45ba5426c1 libstdc++: Fix std::numeric_limits::lowest() test for strict modes
This test uses std::is_integral to decide whether we are testing an
integral or floating-point type. But that fails for __int128 because
is_integral<__int128> is false in strict modes. By using
numeric_limits::is_integer instead we get the right answer for all types
that have a numeric_limits specialization.

We can also simplify the test by removing the unnecessary tag
dispatching.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/numeric_limits/lowest.cc: Use
	numeric_limits<T>::is_integer instead of is_integral<T>::value.
2021-10-11 20:34:17 +01:00
Jonathan Wakely
6b6788f8c2 libstdc++: Add valid range assertions to std::basic_regex [PR89927]
This adds some debug assertions to basic_regex. They don't actually
diagnose the error in the PR yet, but I have another patch to make them
more effective.

Also change the __glibcxx_assert(false) consistency checks to include a
string literal that tells the user a bit more about why the process
aborted. We could consider adding a __glibcxx_bug or
__glibcxx_internal_error macro for this purpose, but ideally we'll never
hit such bugs anyway so it shouldn't be needed.

libstdc++-v3/ChangeLog:

	PR libstdc++/89927
	* include/bits/regex.h (basic_regex(const _Ch_type*, size_t)):
	Add __glibcxx_requires_string_len assertion.
	(basic_regex::assign(InputIterator, InputIterator)): Add
	__glibcxx_requires_valid_range assertion.
	* include/bits/regex_scanner.tcc (_Scanner::_M_advance())
	(_Scanner::_M_scan_normal()): Use string literal in assertions.
2021-10-11 20:34:16 +01:00
Jonathan Wakely
84088dc4bb libstdc++: Fix std::match_results::end() for failed matches [PR102667]
The end() function needs to consider whether the underlying vector is
empty, not whether the match_results object is empty. That's because the
underlying vector will always contain at least three elements for a
match_results object that is "ready". It contains three extra elements
which are stored in the vector but are not considered part of sequence,
and so should not be part of the [begin(),end()) range.

libstdc++-v3/ChangeLog:

	PR libstdc++/102667
	* include/bits/regex.h (match_result::empty()): Optimize by
	calling the base function directly.
	(match_results::end()): Check _Base_type::empty() not empty().
	* testsuite/28_regex/match_results/102667.C: New test.
2021-10-11 20:34:16 +01:00
Jonathan Wakely
f858239830 ChangeLog: Remove incorrect PR reference 2021-10-11 16:19:01 +01:00
GCC Administrator
ce6eec3926 Daily bump. 2021-10-09 00:16:26 +00:00
Jonathan Wakely
fec283b63d libstdc++: Remove unnecessary uses of _GLIBCXX_USE_WCHAR_T in testsuite [PR98725]
Now that std::wstring and other specializations for wchar_t are defined
unconditionally, many checks for _GLIBCXX_USE_WCHAR_T in the testsuite
are unnecessary and can be removed. Tests for iostreams, locales, regex
and filesystem::path still need to be guarded by _GLIBCXX_USE_WCHAR_T
because those components depend on libc support in <wchar.h> and other
headers.

libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* testsuite/18_support/numeric_limits/lowest.cc: Remove use of
	_GLIBCXX_USE_WCHAR_T.
	* testsuite/18_support/numeric_limits/min_max.cc: Replace use of
	_GLIBCXX_USE_WCHAR_T with checks for WCHAR_MIN and WCHAR_MAX.
	* testsuite/20_util/from_chars/1_neg.cc: Remove use of
	_GLIBCXX_USE_WCHAR_T.
	* testsuite/20_util/function_objects/searchers.cc: Likewise. Use
	char_traits<wchar_t>::length instead of wcslen.
	* testsuite/20_util/hash/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_arithmetic/value.cc: Likewise.
	* testsuite/20_util/is_compound/value.cc: Likewise.
	* testsuite/20_util/is_floating_point/value.cc: Likewise.
	* testsuite/20_util/is_fundamental/value.cc: Likewise.
	* testsuite/20_util/is_integral/value.cc: Likewise.
	* testsuite/20_util/is_signed/value.cc: Likewise.
	* testsuite/20_util/is_unsigned/value.cc: Likewise.
	* testsuite/20_util/is_void/value.cc: Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs-1.cc:
	Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs-2.cc:
	Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs-3.cc:
	Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs-4.cc:
	Likewise.
	* testsuite/20_util/make_unsigned/requirements/typedefs-1.cc:
	Likewise.
	* testsuite/20_util/make_unsigned/requirements/typedefs-2.cc:
	Likewise.
	* testsuite/20_util/make_unsigned/requirements/typedefs-3.cc:
	Likewise.
	* testsuite/20_util/to_chars/3.cc: Likewise.
	* testsuite/20_util/type_identity/requirements/typedefs.cc:
	Likewise.
	* testsuite/21_strings/basic_string/hash/debug.cc: Likewise.
	* testsuite/21_strings/basic_string/hash/hash.cc: Likewise.
	* testsuite/21_strings/basic_string/literals/types-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string/literals/types.cc: Likewise.
	* testsuite/21_strings/basic_string/literals/values-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string/literals/values.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/64422.cc:
	Likewise.
	* testsuite/21_strings/basic_string/range_access/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/citerators.cc:
	Likewise.
	* testsuite/21_strings/basic_string/requirements/typedefs.cc:
	Likewise.
	* testsuite/21_strings/basic_string/types/pmr_typedefs.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/types-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/types.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/values-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/values.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/typedefs.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/typedefs.cc: Likewise.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions.cc:
	Likewise.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
	Likewise.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
	Likewise.
	* testsuite/22_locale/ctype/is/string/89728_neg.cc: Likewise.
	* testsuite/25_algorithms/fill/4.cc: Likewise.
	* testsuite/25_algorithms/fill_n/1.cc: Likewise.
	* testsuite/experimental/functional/searchers.cc: Likewise. Use
	char_traits<wchar_t>::length instead of wcslen.
	* testsuite/experimental/polymorphic_allocator/pmr_typedefs_string.cc:
	Likewise.
	* testsuite/experimental/string_view/literals/types-char8_t.cc:
	Likewise.
	* testsuite/experimental/string_view/literals/types.cc:
	Likewise.
	* testsuite/experimental/string_view/literals/values-char8_t.cc:
	Likewise.
	* testsuite/experimental/string_view/literals/values.cc:
	Likewise.
	* testsuite/experimental/string_view/range_access/wchar_t/1.cc:
	Likewise.
	* testsuite/experimental/string_view/requirements/typedefs.cc:
	Likewise.
	* testsuite/experimental/string_view/typedefs.cc: Likewise.
	* testsuite/ext/vstring/range_access.cc: Likewise.
	* testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc:
	Likewise.
	* testsuite/std/concepts/concepts.lang/concept.arithmetic/signed_integral.cc:
	Likewise.
	* testsuite/std/concepts/concepts.lang/concept.arithmetic/unsigned_integral.cc:
	Likewise.
	* testsuite/tr1/4_metaprogramming/is_arithmetic/value.cc:
	Likewise.
	* testsuite/tr1/4_metaprogramming/is_compound/value.cc:
	Likewise.
	* testsuite/tr1/4_metaprogramming/is_floating_point/value.cc:
	Likewise.
	* testsuite/tr1/4_metaprogramming/is_fundamental/value.cc:
	Likewise.
	* testsuite/tr1/4_metaprogramming/is_integral/value.cc:
	Likewise.
	* testsuite/tr1/4_metaprogramming/is_signed/value.cc: Likewise.
	* testsuite/tr1/4_metaprogramming/is_unsigned/value.cc:
	Likewise.
	* testsuite/tr1/4_metaprogramming/is_void/value.cc: Likewise.
	* testsuite/tr1/6_containers/hash/24799.cc: Likewise.
2021-10-09 00:57:50 +01:00
Jonathan Wakely
9a89281c40 libstdc++: Define deleted wchar_t overloads unconditionally [PR 98725]
We don't need to have <wchar.h> support in order to delete overloads
for inserting wide characters into narrow streams.

libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* include/std/ostream (operator<<(basic_ostream<char, Tr>&, wchar_t))
	(operator<<(basic_ostream<char, Tr>&, const wchar_t*)): Always
	define as deleted. Do not check _GLIBCXX_USE_WCHAR_T.
2021-10-09 00:57:50 +01:00
Jonathan Wakely
3c9fbc26af libstdc++: Define std::wstring_convert unconditionally [PR 98725]
The wchar_t type is defined unconditionally for C++, so there is no
reason for std::wstring_convert and std::wbuffer_convert to be disabled
when <wchar.h> is not usable. It should be possible to use those class
templates with char16_t and char32_t even if wchar_t conversions don't
work.

libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* include/bits/locale_conv.h (wstring_convert, wbuffer_convert):
	Define unconditionally. Do not check _GLIBCXX_USE_WCHAR_T.
2021-10-09 00:57:49 +01:00
Jonathan Wakely
4bdb9d618d libstdc++: Enable type traits for wchar_t unconditionally [PR98725]
None of these traits depend on libc support for wchar_t, so they should
be defined unconditionally. The wchar_t type is always defined in C++.

libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* include/c_global/cstddef [!_GLIBCXX_USE_WCHAR_T]
	(__byte_operand<wchar_t>): Define specialization.
	* include/std/type_traits (__make_signed<wchar_t>)
	(__make_unsigned<wchar_t>): Remove redundant check for
	__WCHAR_TYPE__ being defined.
	* include/tr1/type_traits [!_GLIBCXX_USE_WCHAR_T]
	(__is_integral_helper<wchar_t>): Likewise.
2021-10-09 00:57:49 +01:00
Jonathan Wakely
4997c8b30e libstdc++: Enable vstring for wchar_t unconditionally [PR98725]
None of these vstring specializations depend on libc support for
wchar_t, so can be enabled unconditionally now that char_traits<wchar_t>
is always available.

libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* include/ext/rc_string_base.h [!_GLIBCXX_USE_WCHAR_T]
	(__rc_string_base<wchar_t>): Define member function.
	* include/ext/vstring.h [!_GLIBCXX_USE_WCHAR_T]
	(hash<__gnu_cxx::__wvstring>): Define specialization.
	* include/ext/vstring_fwd.h [!_GLIBCXX_USE_WCHAR_T] (__wvstring)
	(__wsso_string, __wrc_string): Declare typedefs.
2021-10-09 00:57:49 +01:00
Jonathan Wakely
0afb9ebaab libstdc++: Always define typedefs and hash functions for wide strings [PR 98725]
The wstring and wstring_view typedefs should be enabled even if
<wchar.h> isn't supported, because char_traits<wchar_t> works
unconditionally. Similarly, the std::hash specializations for wide
strings do not depend on <wchar.h> support.

Although the primary template works OK for std::char_traits<wchar_t> in
the absence of <wchar.h> support, this patch still defines it as an
explicit specialization for compatibility with declarations that expect
it to be specialized. The explicit specialization just uses the same
__gnu_cxx::char_traits base class as the primary template.

libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* include/bits/char_traits.h (char_traits<wchar_t>): Define
	explicit specialization unconditionally.
	* include/bits/basic_string.h (hash<wstring>): Define
	unconditionally. Do not check _GLIBCXX_USE_WCHAR_T.
	* include/bits/stringfwd.h (wstring): Likewise.
	* include/debug/string (wstring): Likewise.
	* include/experimental/string_view (experimental::wstring_view)
	(hash<experimental::wstring_view>): Likewise.
	* include/std/string (pmr::wstring, hash<pmr::wstring>):
	Likewise.
	* include/std/string_view (wstring_view, hash<wstring_view>):
	Likewise.
2021-10-09 00:57:49 +01:00
Jonathan Wakely
cfeff094e6 libstdc++: Move test that depends on wchar_t I/O to wchar_t sub-directory
This fixes a FAIL when --disable-wchar_t is used.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_filebuf/close/81256.cc: Moved to...
	* testsuite/27_io/basic_filebuf/close/wchar_t/81256.cc: ...here.
2021-10-09 00:57:48 +01:00
Jonathan Wakely
43e2a44182 libstdc++: Add missing _GLIBCXX_USE_WCHAR_T checks in testsuite
These tests fail for a --disable-wchar_t build.

libstdc++-v3/ChangeLog:

	* testsuite/22_locale/conversions/buffer/1.cc: Check
	_GLIBCXX_USE_WCHAR_T.
	* testsuite/22_locale/conversions/buffer/3.cc: Likewise. Add
	test using char16_t.
	* testsuite/22_locale/conversions/string/1.cc: Check
	_GLIBCXX_USE_WCHAR_T.
	* testsuite/27_io/filesystem/path/generic/generic_string.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/make_preferred.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/native/alloc.cc: Likewise.
	* testsuite/27_io/filesystem/path/native/string-char8_t.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/native/string.cc: Likewise.
	* testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/generic/generic_string.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/native/alloc.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/native/string-char8_t.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/native/string.cc:
	Likewise.
2021-10-09 00:57:48 +01:00
Jonathan Wakely
29a9de9b40 libstdc++: Replace uses of _GLIBCXX_USE_INT128 in testsuite
Since r12-435 the _GLIBCXX_USE_INT128 macro is never defined, so all
uses of it in the testsuite are wrong. The tests should be checking
__SIZEOF_INT128__ instead.

Also add some tests for an INT_3 type, which were missing.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/numeric_limits/40856.cc: Replace use of
	_GLIBCXX_USE_INT128.
	* testsuite/18_support/numeric_limits/dr559.cc: Likewise.
	* testsuite/18_support/numeric_limits/lowest.cc: Likewise.
	* testsuite/18_support/numeric_limits/max_digits10.cc: Likewise.
	* testsuite/20_util/is_floating_point/value.cc: Likewise.
	* testsuite/20_util/is_integral/value.cc: Likewise.
	* testsuite/20_util/is_signed/value.cc: Likewise.
	* testsuite/20_util/is_unsigned/value.cc: Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs-1.cc:
	Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs-2.cc:
	Likewise.
	* testsuite/20_util/make_unsigned/requirements/typedefs-1.cc:
	Likewise.
	* testsuite/20_util/make_unsigned/requirements/typedefs-2.cc:
	Likewise.
	* testsuite/20_util/type_identity/requirements/typedefs.cc:
	Likewise.
	* testsuite/26_numerics/bit/bit.count/countl_one.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/countl_zero.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/countr_one.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/countr_zero.cc: Likewise.
	* testsuite/26_numerics/bit/bit.count/popcount.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/bit_ceil.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/bit_floor.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/bit_width.cc: Likewise.
	* testsuite/26_numerics/bit/bit.pow.two/has_single_bit.cc:
	Likewise.
	* testsuite/26_numerics/bit/bit.rotate/rotl.cc: Likewise.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/bit/bit.rotate/rotr.cc:
	* testsuite/util/testsuite_common_types.h:
2021-10-09 00:57:48 +01:00
Jonathan Wakely
d87105d697 libstdc++: Access std::pair members without tuple-like helpers
This avoids the tuple-like API for std::pair in the unordered
containers, removing some overly generic code.

The _Select1st projection can figure out the member types of a std::pair
without using decltype(std::get<0>(...)).

We don't need _Select2nd because it's only needed in
_NodeBuilder::_S_build, and that can just access the .second member of
the pair directly. The return type of that function doesn't need to be
deduced by decltype, we can just expose the __node_type typedef of the
node generator.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h (_Select1st): Replace use of
	std::get.
	(_Select2nd): Remove.
	(_NodeBuilder::_S_build): Use _NodeGenerator::__node_type
	typedef instead of deducing it. Remove unnecessary piecewise
	construction.
	(_ReuseOrAllocNode): Make __node_type public.
	(_Map_base): Adjust partial specialization to be able to extract
	the mapped_type without using tuple_element.
	(_Map_base::at): Define inline
	* testsuite/23_containers/unordered_map/requirements/53339.cc:
	Remove XFAIL.
	* testsuite/23_containers/unordered_multimap/requirements/53339.cc:
	Likewise.
2021-10-09 00:57:47 +01:00
Jonathan Wakely
64acc43de1 libstdc++: Avoid instantiation of _Hash_node before it's needed
This is a step towards restoring support for incomplete types in
unordered containers (PR 53339).

We do not need to instantiate the node type to get its value_type
member, because we know that the value type is the first template
parameter. We can deduce that template argument using a custom trait and
a partial specialization for _Hash_node. If we wanted to support custom
hash node types we could still use typename _Tp::value_type in the
primary template of that trait, but that seems unnecessary.

The other change needed is to defer a static assert at class scope, so
that it is done when the types are complete. We must have a complete
type in the destructor, so we can do it there instead.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h: Move static assertion to destructor.
	* include/bits/hashtable_policy.h: Deduce value type from node
	type without instantiating it.
2021-10-09 00:57:47 +01:00
Jonathan Wakely
e6f6972b5f libstdc++: Detect miscompilation of src/c++11/limits.cc
Add a #error directive to ensure that the definitions are not compiled
as C++17, which would prevent them being emitted.

libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* src/c++11/limits.cc: Fail if __cpp_inline_variables is
	defined.
2021-10-08 15:51:08 +01:00
Jonathan Wakely
a1fc4075fc libstdc++: Reduce header dependencies of <algorithm> in C++20 [PR 92546]
The <bits/ranges_algobase.h> header doesn't need the stream and
streambuf iterators, so don't include the whole of <iterator>.

libstdc++-v3/ChangeLog:

	PR libstdc++/92546
	* include/bits/ranges_algobase.h: Replace <iterator> with a
	subset of the headers it includes.
2021-10-08 15:00:06 +01:00
Jonathan Wakely
82e3a82687 libstdc++: Restore debug checks in uniform container erasure functions
This partially reverts commit 561078480f.

If we avoid all debug mode checks when erasing elements then we fail to
invalidate safe iterators to the removed elements. This reverts the
recent changes in r12-4083 and r12-4233, restoring the debug checking.

libstdc++-v3/ChangeLog:

	* include/experimental/deque (erase, erase_if): Revert changes
	to avoid debug mode overhead.
	* include/experimental/map (erase, erase_if): Likewise.
	* include/experimental/set (erase, erase_if): Likewise.
	* include/experimental/unordered_map (erase, erase_if):
	Likewise.
	* include/experimental/unordered_set (erase, erase_if):
	Likewise.
	* include/experimental/vector (erase, erase_if): Likewise.
	* include/std/deque (erase, erase_if): Likewise.
	* include/std/map (erase, erase_if): Likewise.
	* include/std/set (erase, erase_if): Likewise.
	* include/std/unordered_map (erase, erase_if): Likewise.
	* include/std/unordered_set (erase, erase_if): Likewise.
	* include/std/vector (erase, erase_if): Likewise.
2021-10-08 12:20:25 +01:00
Jonathan Wakely
fcc13d6fc3 libstdc++: Implement ostream insertion for chrono::duration
This is a missing piece of the C++20 <chrono> header.

It would be good to move the code into the compiled library, so that we
don't need <sstream> in <chrono>. It could also use spanstream in C++20,
to avoid memory allocations. That can be changed at a later date.

libstdc++-v3/ChangeLog:

	* include/std/chrono (__detail::__units_suffix_misc): New
	helper function.
	(__detail::__units_suffix): Likewise.
	(chrono::operator<<(basic_ostream&, const duration&)): Define.
	* testsuite/20_util/duration/io.cc: New test.
2021-10-08 12:19:19 +01:00
GCC Administrator
50e20ee6e4 Daily bump. 2021-10-08 00:16:28 +00:00
Jonathan Wakely
7f78718b79 libstdc++: Move C++14 <chrono> components to new <bits/chrono.h> header
This moves the "classic" contents of <chrono> to a new header, so that
<future>, <thread> etc. can get use durations and clocks without
calendar types, time zones, and chrono I/O.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/std/chrono (duration, time_point, system_clock)
	(steady_clock, high_resolution_clock, chrono_literals, sys_time)
	(file_clock, file_time): Move to ...
	* include/bits/chrono.h: New file.
	* include/bits/atomic_futex.h: Include new header instead of
	<chrono>.
	* include/bits/atomic_timed_wait.h: Likewise.
	* include/bits/fs_fwd.h: Likewise.
	* include/bits/semaphore_base.h: Likewise.
	* include/bits/this_thread_sleep.h: Likewise.
	* include/bits/unique_lock.h: Likewise.
	* include/experimental/bits/fs_fwd.h: Likewise.
	* include/experimental/chrono: Likewise.
	* include/experimental/io_context: Likewise.
	* include/experimental/netfwd: Likewise.
	* include/experimental/timer: Likewise.
	* include/std/condition_variable: Likewise.
	* include/std/mutex: Likewise.
	* include/std/shared_mutex: Likewise.
2021-10-07 21:12:32 +01:00
Jonathan Wakely
0e90799071 libstdc++: Avoid use of hardware interference non-constant [PR102377]
libstdc++-v3/ChangeLog:

	PR libstdc++/102377
	* include/bits/atomic_wait.h (__waiter_pool_base:_S_align):
	Hardcode to 64 instead of using non-constant constant.
2021-10-07 18:35:16 +01:00
Jonathan Wakely
561078480f libstdc++: Avoid debug checks in uniform container erasure functions
In commit r12-4083 I tried to make the std::erase and std::erase_if
function avoid the unnecessary overhead of safe iterators. It didn't
work, for two reasons. Firstly, for the RB tree containers the
__niter_base function is a no-op (because the iterators aren't
random access) so the safe iterators were still used. Secondly, for the
cases where __niter_base did remove the safe iterator layer, there was
still unnecessary overhead to create a new safe iterator and link it to
the container.

This solves the problem by simply binding a reference to the non-debug
version of the conainer. For normal mode this is a no-op, and for debug
mode it binds a reference to the debug container's base class. That
means the rest of the function operates directly on the non-debug
container, and avoids all checking.

For std::basic_string there's no need to unwrap anything, because we use
std::basic_string directly in debug mode anyway.

libstdc++-v3/ChangeLog:

	* include/bits/erase_if.h (__erase_nodes_if): Remove redundant
	__niter_base calls.
	* include/std/string (erase, erase_if): Likewise.
	* include/std/deque (erase, erase_if): Access non-debug
	container directly.
	* include/std/map (erase, erase_if): Likewise.
	* include/std/set (erase, erase_if): Likewise.
	* include/std/unordered_map (erase, erase_if): Likewise.
	* include/std/unordered_set (erase, erase_if): Likewise.
	* include/std/vector (erase, erase_if): Likewise.
	* include/experimental/deque (erase, erase_if): Likewise.
	* include/experimental/map (erase, erase_if): Likewise.
	* include/experimental/set (erase, erase_if): Likewise.
	* include/experimental/unordered_map (erase, erase_if):
	Likewise.
	* include/experimental/unordered_set (erase, erase_if):
	Likewise.
	* include/experimental/vector (erase, erase_if): Likewise.
2021-10-07 17:52:04 +01:00
GCC Administrator
57c7ec62ee Daily bump. 2021-10-07 00:16:24 +00:00
Jonathan Wakely
881d1689a4 libstdc++: Implement std::move_only_function for C++23 (P0288R9)
libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/std/functional: Include <bits/move_only_function.h>.
	* include/std/version (__cpp_lib_move_only_function): Define.
	* include/bits/mofunc_impl.h: New file.
	* include/bits/move_only_function.h: New file.
	* testsuite/20_util/move_only_function/call.cc: New test.
	* testsuite/20_util/move_only_function/cons.cc: New test.
	* testsuite/20_util/move_only_function/move.cc: New test.
	* testsuite/20_util/move_only_function/version.cc: New test.
2021-10-06 20:12:01 +01:00
GCC Administrator
bb6194e0b4 Daily bump. 2021-10-06 00:16:30 +00:00