Commit Graph

13126 Commits

Author SHA1 Message Date
GCC Administrator fc82978278 Daily bump. 2022-01-18 00:16:54 +00:00
Patrick Palka 490e23032b libstdc++: Use fast_float in std::from_chars for binary32/64
This makes our std::from_chars implementation use fast_float for decimal
parsing of binary32/64 numbers.  For other floating-point formats we
still use the fallback implementation that goes through the strtod family
of functions.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_from_chars.cc: (USE_LIB_FAST_FLOAT):
	Conditionally define, and use it to conditionally include
	fast_float.
	(from_chars): Use fast_float for float and double when
	USE_LIB_FAST_FLOAT.
2022-01-17 14:33:12 -05:00
Patrick Palka 40b0d4472a libstdc++: Adjust fast_float's over/underflow behavior for conformance
This changes fast_float's handling of overflow/underflow to be
consistent with the standard: instead of returning errc{} and setting
value to +-0 or +-infinity, just return errc::result_out_of_range and
don't modify value, as per [charconv.from.chars]/1.

libstdc++-v3/ChangeLog:

	* src/c++17/fast_float/LOCAL_PATCHES: Update.
	* src/c++17/fast_float/fast_float.h (from_chars_advanced): In
	case of over/underflow, return errc::result_out_of_range and don't
	modify 'value'.
2022-01-17 14:32:30 -05:00
Patrick Palka f5c8b82512 libstdc++: Apply modifications to our local copy of fast_float
This performs the following modifications to our local copy of fast_float
in order to make it more readily usable in our std::from_chars
implementation:

  * Remove system #includes
  * Replace stray call to assert
  * Use the standard chars_format and from_chars_result types

libstdc++-v3/ChangeLog:

	* src/c++17/fast_float/LOCAL_PATCHES: Update.
	* src/c++17/fast_float/fast_float.h: Apply local modifications.
2022-01-17 14:32:27 -05:00
Patrick Palka 2800bc08e4 libstdc++: Import the fast_float library
We're going to use the fast_float library[1] in our (compiled-in)
floating-point std::from_chars implementation for faster and more
portable parsing of binary32/64 decimal strings.

The single file fast_float.h is an amalgamation of the entire library,
which can be (re)generated with the amalgamate.py script (from the
fast_float repository) via the command

  python3 ./script/amalgamate.py --license=MIT \
    > $GCC_SRC/libstdc++-v3/c++17/fast_float/fast_float.h

The code has a GPL-compatible license.

[1]: https://github.com/fastfloat/fast_float

libstdc++-v3/ChangeLog:

	* src/c++17/fast_float/LOCAL_PATCHES: New file.
	* src/c++17/fast_float/MERGE: New file.
	* src/c++17/fast_float/README.md: New file, copied from the
	fast_float repository.
	* src/c++17/fast_float/fast_float.h: New file, an amalgamation
	of the fast_float library.

Signed-off-by: Patrick Palka <ppalka@redhat.com>
2022-01-17 14:32:16 -05:00
Patrick Palka cc3bf3404e libstdc++: Directly implement hexfloat std::from_chars for binary32/64
libstdc++-v3/ChangeLog:

	* src/c++17/floating_from_chars.cc: Include <bit>.
	(ascii_to_hexit, starts_with_ci): Conditionally define.
	(__floating_from_chars_hex):  Conditionally define.
	(from_chars): Use __floating_from_chars_hex for
	chars_format::hex parsing of binary32/64 float/double.
	(testsuite/20_util/from_chars/7.cc): New test.
2022-01-17 14:32:13 -05:00
Jonathan Wakely 3acb929cc0 libstdc++: Define <stacktrace> header for C++23
Add the <stacktrace> header and a new libstdc++_libbacktrace.a library
that provides the implementation. For now, the new library is only built
if --enable-libstdcxx-backtrace=yes is used. As with the Filesystem TS,
the new library is only provided as a static archive.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): New macro.
	* configure.ac: Use GLIBCXX_ENABLE_BACKTRACE.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/std/stacktrace: New header.
	* include/std/version (__cpp_lib_stacktrace): Define.
	* Makefile.in: Regenerate.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.am: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.am: New file.
	* src/libbacktrace/Makefile.in: New file.
	* src/libbacktrace/backtrace-rename.h: New file.
	* src/libbacktrace/backtrace-supported.h.in: New file.
	* src/libbacktrace/config.h.in: New file.
	* testsuite/lib/libstdc++.exp (check_effective_target_stacktrace):
	New proc.
	* testsuite/20_util/stacktrace/entry.cc: New test.
	* testsuite/20_util/stacktrace/synopsis.cc: New test.
	* testsuite/20_util/stacktrace/version.cc: New test.
2022-01-17 12:13:02 +00:00
Jonathan Wakely 5a3dc58a1d libstdc++: Document final option names for enabling C++20
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2020.xml: Use final C++20 option
	names.
	* doc/html/manual/status.html: Regenerate.
2022-01-17 12:08:37 +00:00
Jonathan Wakely fa092570fb libstdc++: Rename non-reserved macros in config header [PR103650]
libstdc++-v3/ChangeLog:

	PR libstdc++/103650
	* include/Makefile.am: Rename LT_OBJDIR and STDC_HEADERS.
	* include/Makefile.in: Regenerate.
	* testsuite/17_intro/headers/c++1998/103650.cc: New test.
2022-01-17 12:08:26 +00:00
Matthias Kretz 84eb13b9d6 libstdc++: Don't fail if math_errhandling is not defined
Older glibc does not define math_errhandling with -ffast-math, in which
case floating-point exceptions are not used.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h (__floating_point_flags): Do
	not rely on the presence of the math_errhandling macro.
2022-01-17 11:27:32 +01:00
Jonathan Wakely a923345c72 libstdc++: Add 'typename' to dependent types in atomic<shared_ptr<T>>
libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (_Sp_atomic): Add typename
	to qualified-id for dependent type.
2022-01-17 09:48:09 +00:00
GCC Administrator 1e942d7c05 Daily bump. 2022-01-17 00:16:24 +00:00
Jonathan Wakely a326934886 libstdc++: Update C++20 status table
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2020.xml: Update.
	* doc/html/manual/status.html: Regenerate.
2022-01-17 00:06:28 +00:00
Jonathan Wakely 2ac0649d7b libstdc++: Implement C++20 atomic<shared_ptr> and atomic<weak_ptr>
This adds another piece of C++20, the std::atomic specializations for
std::shared_ptr and std::weak_ptr.

The new _Sp_atomic type mimics the structure of shared_ptr<T> and
weak_ptr<T>, holding a T* pointer (the one returned by get() on a
shared_ptr/weak ptr) and a _Sp_counted_base<>* pointer to the
ref-counted control block. For _Sp_atomic the low bit of the control
block pointer is used as a lock bit, to ensure only one thread will
access the object at a time.  The pointer is actually stored as a
uintptr_t to avoid accidental dereferences of the pointer when unlocked
(which would be a race) or when locked (which would dereference the
wrong pointer value due to the low bit being set). To get a raw pointer
to the control block, the lock must be acquired. Converting between a
_Sp_atomic and a shared_ptr or weak_ptr requires manually adjusting the
T* and _Sp_counted_base<>* members of the shared/weak ptr, instead of
going through the public API. This must be done carefully to ensure that
any change in the number of owners is reflected in a ref-count update.

Co-authored-by: Thomas Rodgers <trodgers@redhat.com>
Signed-off-by: Thomas Rodgers <trodgers@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (__cpp_lib_atomic_shared_ptr):
	New macro.
	(_Sp_atomic): New class template.
	(atomic<shared_ptr<T>>, atomic<weak_ptr<T>>): New partial
	specializations.
	* include/bits/shared_ptr_base.h (__shared_count, __weak_count)
	(__shared_ptr, __weak_ptr): Declare _Sp_atomic as a friend.
	* include/std/version (__cpp_lib_atomic_shared_ptr): New macro.
	* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc: New
	test.
	* testsuite/20_util/weak_ptr/atomic_weak_ptr.cc: New test.
2022-01-17 00:06:28 +00:00
GCC Administrator 9248ee4147 Daily bump. 2022-01-16 00:16:26 +00:00
Matthias Kretz 52d2821038 libstdc++: Fix ODR issues with different -m flags
Explicitly support use of the stdx::simd implementation in situations
where the user links TUs that were compiled with different -m flags. In
general, this is always a (quasi) ODR violation for inline functions
because at least codegen may differ in important ways. However, in the
resulting executable only one (unspecified which one) of them might be
used. For simd we want to support users to compile code multiple times,
with different -m flags and have a runtime dispatch to the TU matching
the target CPU. But if internal functions are not inlined this may lead
to unexpected performance loss or execution of illegal instructions.
Therefore, inline functions that are not marked as always_inline must
use an additional template parameter somewhere in their name, to
disambiguate between the different -m translations.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h: Move feature detection bools
	and add __have_avx512bitalg, __have_avx512vbmi2,
	__have_avx512vbmi, __have_avx512ifma, __have_avx512cd,
	__have_avx512vnni, __have_avx512vpopcntdq.
	(__detail::__machine_flags): New function which returns a unique
	uint64 depending on relevant -m and -f flags.
	(__detail::__odr_helper): New type alias for either an anonymous
	type or a type specialized with the __machine_flags number.
	(_SimdIntOperators): Change template parameters from _Impl to
	_Tp, _Abi because _Impl now has an __odr_helper parameter which
	may be _OdrEnforcer from the anonymous namespace, which makes
	for a bad base class.
	(many): Either add __odr_helper template parameter or mark as
	always_inline.
	* include/experimental/bits/simd_detail.h: Add defines for
	AVX512BITALG, AVX512VBMI2, AVX512VBMI, AVX512IFMA, AVX512CD,
	AVX512VNNI, AVX512VPOPCNTDQ, and AVX512VP2INTERSECT.
	* include/experimental/bits/simd_builtin.h: Add __odr_helper
	template parameter or mark as always_inline.
	* include/experimental/bits/simd_fixed_size.h: Ditto.
	* include/experimental/bits/simd_math.h: Ditto.
	* include/experimental/bits/simd_scalar.h: Ditto.
	* include/experimental/bits/simd_neon.h: Add __odr_helper
	template parameter.
	* include/experimental/bits/simd_ppc.h: Ditto.
	* include/experimental/bits/simd_x86.h: Ditto.
2022-01-15 21:05:17 +01:00
GCC Administrator 617db51d7e Daily bump. 2022-01-15 00:16:27 +00:00
Uros Bizjak 6795e6ae66 libstdc++: Fix 22_locale/numpunct/members/char/3.cc execution test
The test fails on Fedora 33+ because nl_NL locale got thousands
separator defined.  Use one of ar_SA, bg_BG, bs_BA, pt_PT
or plain C locale instead.

2022-01-14  Uroš Bizjak  <ubizjak@gmail.com>

libstdc++-v3/ChangeLog:

	* testsuite/22_locale/numpunct/members/char/3.cc:
	Require pt_PT locale instead of nl_NL.
	(test02): Use pt_PT locale instead of nl_NL.
2022-01-14 16:21:57 +01:00
Jonathan Wakely de196e5dd8 libstdc++: Add attribute to features deprecated in C++17 [PR91260]
There are a lot of things in the C++ standard library which were
deprecated in C++11, and more in C++17.  Some of them were removed after
deprecation and are no longer present in the standard at all. We have
not removed these from libstdc++ because keeping them as non-standard
extensions is conforming, and avoids gratuitously breaking user code,
and in some cases we need to keep using them to avoid ABI changes. But
we should at least give a warning for using them. That has not been done
previously because of the library's own uses of them (e.g. the
std::iterator class template used as a base class).

This adds deprecated attributes to the relevant components, and then
goes through the whole library to add diagnostic pragmas where needed to
suppress warnings about our internal uses of them. The tests are updated
to either expect the additional warnings, or to suppress them where we
aren't interested in them.

libstdc++-v3/ChangeLog:

	PR libstdc++/91260
	PR libstdc++/91383
	PR libstdc++/95065
	* include/backward/binders.h (bind1st, bind2nd): Add deprecated
	attribute.
	* include/bits/refwrap.h (_Maybe_unary_or_binary_function):
	Disable deprecated warnings for base classes.
	(_Reference_wrapper_base): Likewise.
	* include/bits/shared_ptr_base.h (_Sp_owner_less): Likewise.
	* include/bits/stl_bvector.h (_Bit_iterator_base): Likewise.
	* include/bits/stl_function.h (unary_function, binary_function):
	Add deprecated attribute.
	(unary_negate, not1, binary_negate, not2, ptr_fun)
	(pointer_to_unary_function, pointer_to_binary_function)
	(mem_fun_t, const_mem_fun_t, mem_fun_ref_t, const_mem_fun_ref_t)
	(mem_fun1_t, const_mem_fun1_t, mem_fun_ref1_t)
	(const_mem_fun1_ref_t, mem_fun, mem_fun_ref): Add deprecated
	attributes.
	* include/bits/stl_iterator.h: Disable deprecated warnings for
	std::iterator base classes.
	* include/bits/stl_iterator_base_types.h (iterator): Add
	deprecated attribute.
	* include/bits/stl_map.h (map::value_compare): Disable
	deprecated warnings for base class.
	* include/bits/stl_multimap.h (multimap::value_compare):
	Likewise.
	* include/bits/stl_raw_storage_iter.h (raw_storage_iterator):
	Add deprecated attribute.
	* include/bits/stl_tempbuf.h (get_temporary_buffer): Likewise.
	* include/bits/stream_iterator.h: Disable deprecated warnings.
	* include/bits/streambuf_iterator.h: Likewise.
	* include/ext/bitmap_allocator.h: Remove unary_function base
	classes.
	* include/ext/functional: Disable deprecated warnings.
	* include/ext/rope: Likewise.
	* include/ext/throw_allocator.h: Likewise.
	* include/std/type_traits (result_of): Add deprecated attribute.
	* include/tr1/functional: Disable deprecated warnings.
	* include/tr1/functional_hash.h: Likewise.
	* testsuite/20_util/function_objects/binders/1.cc: Add
	-Wno-disable-deprecations.
	* testsuite/20_util/function_objects/binders/3113.cc: Likewise.
	* testsuite/20_util/function_objects/constexpr.cc: Add
	dg-warning.
	* testsuite/20_util/raw_storage_iterator/base.cc: Likewise.
	* testsuite/20_util/raw_storage_iterator/dr2127.cc: Likewise.
	* testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc:
	Likewise.
	* testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc:
	Likewise.
	* testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/reference_wrapper/24803.cc:
	Likewise.
	* testsuite/20_util/reference_wrapper/typedefs.cc: Enable for
	C++20 and check for absence of nested types.
	* testsuite/20_util/shared_ptr/comparison/less.cc: Remove
	std::binary_function base class.
	* testsuite/20_util/temporary_buffer.cc: Add dg-warning.
	* testsuite/21_strings/basic_string/cons/char/69092.cc: Remove
	std::iterator base class.
	* testsuite/24_iterators/back_insert_iterator/requirements/base_classes.cc:
	Likewise.
	* testsuite/24_iterators/front_insert_iterator/requirements/base_classes.cc:
	Likewise.
	* testsuite/24_iterators/insert_iterator/requirements/base_classes.cc:
	Likewise.
	* testsuite/24_iterators/istream_iterator/requirements/base_classes.cc:
	Likewise.
	* testsuite/24_iterators/istreambuf_iterator/92285.cc:
	Likewise.
	* testsuite/24_iterators/istreambuf_iterator/requirements/base_classes.cc:
	Likewise.
	* testsuite/24_iterators/ostream_iterator/requirements/base_classes.cc:
	Likewise.
	* testsuite/24_iterators/ostreambuf_iterator/requirements/base_classes.cc:
	Likewise.
	* testsuite/24_iterators/reverse_iterator/requirements/base_classes.cc:
	Likewise.
	* testsuite/25_algorithms/copy/34595.cc:
	Likewise.
	* testsuite/25_algorithms/minmax/3.cc: Remove std::binary_function
	base class.
	* testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc:
	Disable deprecated warnings.
	* testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/count_if/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/count_if/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/find_end/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/find_end/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/find_if/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/find_if/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/for_each/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/for_each/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/partition/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/partition/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/search/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/search/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/transform/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/transform/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/underflow/wchar_t/9178.cc: Add
	dg-warning.
	* testsuite/ext/pb_ds/example/priority_queue_erase_if.cc:
	Likewise.
	* testsuite/ext/pb_ds/example/priority_queue_split_join.cc:
	Likewise.
	* testsuite/tr1/3_function_objects/reference_wrapper/typedefs.cc:
	Disable deprecated warnings.
	* testsuite/tr1/6_containers/hash/requirements/base_classes.cc:
	Likewise.
	* testsuite/util/regression/trait/erase_if_fn.hpp: Remove
	std::unary_function base classes.
	* testsuite/util/testsuite_iterators.h (output_iterator_wrapper):
	Remove std::iterator base classes.
2022-01-14 11:27:50 +00:00
Jonathan Wakely 9a0b518a82 libstdc++: Add C++20 std::make_shared enhancements (P0674R1)
This adds the overloads of std::make_shared and std::allocate_shared for
creating arrays, added to C++20 by P0674R1.

It also adds std::make_shared_for_overwrite, added to C++20 by P1020R1
(and renamed by P1973R1). The std::make_unique_for_overwite overloads
are already supported.

The original std::make_shared overload is changed to construct a
shared_ptr directly instead of calling std::allocate_shared. This
removes a function call at runtime, and avoids having to do overload
resolution for std::allocate_shared, now that there are five overloads
of it.

Allocating a shared array is done by a new __shared_count constructor.
An array is allocated with space for additional elements at the end and
an instance of new _Sp_counted_array class template is constructed in
that unused capacity.

The non-array form of std::make_shared_for_overwrite uses the same
__shared_count constructor as the original std::make_shared overload,
but a new partial specialization of _Sp_counted_ptr_inplace is selected
when the allocator's value_type is the new _Sp_overwrite_tag type. That
new partial specialization default-initializes its contained object and
destroys it with a destructor call rather than using the allocator.

Despite being C++20 features, this implementation only uses concepts
conditionally, with workarounds when they are not supported. This allows
it to work with older non-GCC compilers (Clang 9 and icc 2021). At some
point we can simplify the code by removing the workarounds.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr.h (__cpp_lib_shared_ptr_weak_type):
	Correct type of macro value.
	(shared_ptr): Add additional friend declarations.
	(make_shared, allocate_shared): Constrain existing overloads and
	remove static_assert.
	* include/bits/shared_ptr_base.h (__cpp_lib_smart_ptr_for_overwrite):
	New macro.
	(_Sp_counted_ptr_inplace<T, Alloc, Lp>): New partial
	specialization for use with make_shared_for_overwrite.
	(__cpp_lib_shared_ptr_arrays): Update value for C++20.
	(_Sp_counted_array_base): New class template.
	(_Sp_counted_array): New class template.
	(__shared_count(_Tp*&, const _Sp_counted_array_base&, _Init)):
	New constructor for allocating shared arrays.
	(__shared_ptr(const _Sp_counted_array_base&, _Init)): Likewise.
	* include/std/version (__cpp_lib_shared_ptr_weak_type): Correct
	type.
	(__cpp_lib_shared_ptr_arrays): Update value for C++20.
	(__cpp_lib_smart_ptr_for_overwrite): New macro.
	* testsuite/20_util/shared_ptr/creation/99006.cc: Adjust
	expected errors.
	* testsuite/20_util/shared_ptr/creation/array.cc: New test.
	* testsuite/20_util/shared_ptr/creation/overwrite.cc: New test.
	* testsuite/20_util/shared_ptr/creation/version.cc: New test.
	* testsuite/20_util/unique_ptr/creation/for_overwrite.cc: Check
	feature test macro. Test non-trivial default-initialization.
2022-01-14 10:14:25 +00:00
Jonathan Wakely fc6f1128ae libstdc++: Ignore cv-quals when std::allocator<void> constructs
When I added the std::allocator_traits<std::allocator<void>>
specialization it broke code like this:

  std::allocate_shared<const int>(std::allocator<void>());

The problem is that allocator_traits<allocator<void>>::construct(a, p)
now uses std::_Construct(p), which only does a static_cast<void*>(p) and
so fails if the pointer has cv-quals.

This changes std::_Construct (and the related std::_Construct_novalue)
to use a C-style cast to (void*) which matches the effects of the
"voidify" helper in the C++20 standard.

libstdc++-v3/ChangeLog:

	* include/bits/stl_construct.h (_Construct, _Construct_novalue):
	Also cast away cv-qualifiers when converting pointer to void.
	* testsuite/20_util/allocator/void.cc: Test construct function
	with cv-qualified types.
2022-01-14 10:14:25 +00:00
Jonathan Wakely d67ba1dce9 libstdc++: Use std::construct_at in std::common_iterator [PR103992]
This should have been done as part of the LWG 3574 changes.

libstdc++-v3/ChangeLog:

	PR libstdc++/103992
	* include/bits/stl_iterator.h (common_iterator): Use
	std::construct_at instead of placement new.
	* testsuite/24_iterators/common_iterator/1.cc: Check copy
	construction is usable in constant expressions.
2022-01-14 10:14:24 +00:00
Jonathan Wakely 7f390f11b4 libstdc++: Document new std::random_device tokens
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2011.xml: Document new tokens
	accepted by std::random_device constructor.
	* doc/html/manual/status.html: Regenerate.
2022-01-14 10:14:24 +00:00
GCC Administrator 02a8a01bf3 Daily bump. 2022-01-13 00:16:21 +00:00
Patrick Palka acc38526f6 libstdc++: Add explicit dg-do directive to .../103955.cc
libstdc++-v3/ChangeLog:

	* testsuite/20_util/to_chars/103955.cc: Add explicit dg-do
	directive.
2022-01-12 11:39:48 -05:00
Patrick Palka c0e355c779 libstdc++: Avoid overflow in bounds checks [PR103955]
We currently crash when the floating-point to_chars overloads are passed
a precision value near INT_MAX, ultimately due to overflow in the bounds
checks that verify the output range is large enough.

The simplest portable fix seems to be to replace bounds checks of the form
A >= B + C (where B + C may overflow) with the otherwise equivalent check
A >= B && A - B >= C, which is the approach this patch takes.

Before we could do this in __floating_to_chars_hex, there we first need
to track the unbounded "excess" precision (i.e. the number of trailing
fractional digits in the output that are guaranteed to be '0') separately
from the bounded "effective" precision (i.e. the number of significant
fractional digits in the output), like we do in __f_t_c_precision.

	PR libstdc++/103955

libstdc++-v3/ChangeLog:

	* src/c++17/floating_to_chars.cc (__floating_to_chars_hex):
	Track the excess precision separately from the effective
	precision.  Avoid overflow in bounds check by splitting it into
	two checks.
	(__floating_to_chars_precision): Avoid overflow in bounds checks
	similarly.
	* testsuite/20_util/to_chars/103955.cc: New test.
2022-01-12 09:10:24 -05:00
GCC Administrator 01a254e3e5 Daily bump. 2022-01-12 00:16:39 +00:00
Jonathan Wakely 8b35f02ed5 libstdc++: Install <source_location> header for freestanding [PR103726]
This C++20 header is also supposed to be present for freestanding.

libstdc++-v3/ChangeLog:

	PR libstdc++/103726
	* include/Makefile.am: Install <source_location> for
	freestanding.
	* include/Makefile.in: Regenerate.
	* include/std/version (__cpp_lib_source_location): Define for
	freestanding.
2022-01-11 18:36:36 +00:00
Jonathan Wakely 46de918f98 libstdc++: Add missing noexcept to lazy_split_view iterator (LWG 3593)
This was approved at the October 2021 plenary. We already have noexcept
in the other places the issue adds it in the spec.

libstdc++-v3/ChangeLog:

	* include/std/ranges (ranges::lazy_split_view::_InnerIter::end()):
	Add neoxcept (LWG 3593).
2022-01-11 15:17:27 +00:00
Jonathan Wakely d2dc5305d8 libstdc++: Make copyable-box completely constexpr (LWG 3572)
This LWG issue was approved at the October 2021 plenary and can be
implemented now that std::optional is fully constexpr.

libstdc++-v3/ChangeLog:

	* include/std/ranges (ranges::__detail::__box): Add constexpr to
	assignment operators (LWG 3572).
	* testsuite/std/ranges/adaptors/filter.cc: Check assignment of a
	view that uses copyable-box.
2022-01-11 15:17:26 +00:00
Jonathan Wakely 265d3e1a4e libstdc++: Install <coroutine> header for freestanding [PR103726]
The standard says that <coroutine> should be present for freestanding.
That was intentionally left out of the initial implementation, but can
be done without much trouble. The header should be moved to libsupc++ at
some point in stage 1.

The standard also says that <coroutine> defines a std::hash
specialization, which was missing from our implementation. That's a
problem for freestanding (see LWG 3653) so only do that for hosted.

We can use concepts to constrain the __coroutine_traits_impl base class
when compiled with concepts enabled. In a pure C++20 implementation we
would not need that base class at all and could just use a constrained
partial specialization of coroutine_traits. But the absence of the
__coroutine_traits_impl<R, void> base would create an ABI difference
between the non-standard C++14/C++17 support for coroutines and the same
code compiled as C++20. If we drop support for <coroutine> pre-C++20 we
should revisit this.

libstdc++-v3/ChangeLog:

	PR libstdc++/103726
	* include/Makefile.am: Install <coroutine> for freestanding.
	* include/Makefile.in: Regenerate.
	* include/std/coroutine: Adjust headers and preprocessor
	conditions.
	(__coroutine_traits_impl): Use concepts when available.
	[_GLIBCXX_HOSTED] (hash<coroutine_handle>): Define.
2022-01-11 13:28:46 +00:00
Jonathan Wakely e4fe6dba90 libstdc++: Optimize std::ostream inserters for single characters
On the libsdc++ mailing list Lewis Hyatt pointed out the performance
overhead of using sputn in stream inserters, rather than writing
directly to the streambuf's put area:
https://gcc.gnu.org/pipermail/libstdc++/2021-July/052877.html

As Lewis noted, the standard explicitly requires a call to sputn for
inserting a std::basic_string_view or std::basic_string.  But for
inserting single characters or null-terminated strings it is more vague,
and so we can improve performance by not using the __ostream_insert
function.

This is a minimal change that avoids __ostream_insert for single
characters. We can use the unformatted basic_ostream::put(charT)
function when we don't need the additional effects of a formatted output
function (i.e. padding and resetting the width). The put function will
insert into the buffer if possible, and only make a virtual call (to
overflow) if the buffer is full.

We could also avoid sputn when inserting null-terminated character
strings, but that would require using a new function for inserting
null-terminated strings, so the existing code using sputn is still used
for basic_string and basic_string_view. My preference is to leave that
for now, and try to improve the standard. We could either remove the
requirement to call sputn, or allow sputn to write directly to the
buffer instead of calling xsputn.

libstdc++-v3/ChangeLog:

	* include/std/ostream (operator<<(basic_ostream&, charT)):
	Use unformatted input if no padding is needed.
	(operator<<(basic_ostream<char>&, char)): Likewise.
2022-01-11 13:28:46 +00:00
Jonathan Wakely 5b417b3582 libstdc++: Make std::variant work with Clang in C++20 mode [PR103891]
Clang has some bugs with destructors that use constraints to be
conditionally trivial, so disable the P2231R1 constexpr changes to
std::variant unless the compiler is GCC 12 or later.

If/when P2493R0 gets accepted and implemented by G++ we can remove the
__GNUC__ check and use __cpp_concepts >= 202002 instead.

libstdc++-v3/ChangeLog:

	PR libstdc++/103891
	* include/bits/c++config (_GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS):
	Define.
	* include/std/variant (__cpp_lib_variant): Only define C++20
	value when the compiler is known to support conditionally
	trivial destructors.
	* include/std/version (__cpp_lib_variant): Likewise.
2022-01-11 13:22:35 +00:00
Jonathan Wakely 11d3e8f436 libstdc++: Make std::common_iterator completely constexpr-able (LWG 3574)
This library issue was approved in the October 2021 plenary.

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (common_iterator): Add constexpr
	to all member functions (LWG 3574).
	* testsuite/24_iterators/common_iterator/1.cc: Evaluate some
	tests as constant expressions.
	* testsuite/24_iterators/common_iterator/2.cc: Likewise.
2022-01-11 13:22:34 +00:00
GCC Administrator d9450aa0e8 Daily bump. 2022-01-11 00:16:36 +00:00
Jakub Jelinek a8d3c98746 libstdc++: Add %j, %U, %w, %W time_get support, fix %y, %Y, %C, %p [PR77760]
glibc strptime passes around some state, what fields in struct tm have been
set and what needs to be finalized through possibly recursive calls, and
at the end performs various finalizations, like applying %p so that it
works for both %I %p and %p %I orders, or applying century so that both
%C %y and %y %C works, or computation of missing fields from others
(e.g. from %Y and %j one can compute tm_mon, tm_mday and tm_wday,
from %Y %U %w, %Y %W %w, %Y %U %a, or %Y %W %w one can compute
tm_mon, tm_mday, tm_yday or e.g. from %Y %m %d one can compute tm_wday
and tm_yday.

As the finalization is quite large and doesn't need to be a template
(doesn't depend on any iterators or char types), I've put it into libstdc++,
and left some padding in the state struct, so that perhaps in the future we
can track some more state without changing ABI.

Unfortunately, there is an ugly problem that the standard mandates that
get method calls the do_get virtual method and I don't see how we can
cary on any state in between those calls (even if we did an ABI change
for the facets, the methods are const, so that I think multiple threads
could use the same time_get objects and we couldn't store state in there).

There is a hack for that for GCC (seems to work with ICC too, doesn't work
with clang++) if the do_get method isn't overriden we can pass the state
around.

For both do_get_year and per IRC discussions also for %y, the behavior is
if 1-2 digits are parsed, the year is treated according to POSIX 2008 %y
rules (0-68 is 2000-2068, 69-99 is 1969-1999), if 3-4 digits are parsed,
it is treated as %Y.

2022-01-10  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/77760
	* include/bits/locale_facets_nonio.h (__time_get_state): New struct.
	(time_get::_M_extract_via_format): Declare new method with
	__time_get_state& as an extra argument.
	* include/bits/locale_facets_nonio.tcc (_M_extract_via_format): Add
	__state argument, set various fields in it while parsing.  Handle %j,
	%U, %w and %W, fix up handling of %y, %Y and %C, don't adjust tm_hour
	for %p immediately.  Add a wrapper around the method without the
	__state argument for backwards compatibility.
	(_M_extract_num): Remove all __len == 4 special cases.
	(time_get::do_get_time, time_get::do_get_date, time_get::do_get): Zero
	initialize __state, pass it to _M_extract_via_format and finalize it
	at the end.
	(do_get_year): For 1-2 digit parsed years, map 0-68 to 2000-2068,
	69-99 to 1969-1999.  For 3-4 digit parsed years use that as year.
	(get): If do_get isn't overloaded from the locale_facets_nonio.tcc
	version, don't call do_get but call _M_extract_via_format instead to
	pass around state.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export _M_extract_via_format
	with extra __time_get_state and __time_get_state::_M_finalize_state.
	* src/c++98/locale_facets.cc (is_leap, day_of_the_week,
	day_of_the_year): New functions in anon namespace.
	(mon_yday): New var in anon namespace.
	(__time_get_state::_M_finalize_state): Define.
	* testsuite/22_locale/time_get/get/char/4.cc: New test.
	* testsuite/22_locale/time_get/get/wchar_t/4.cc: New test.
	* testsuite/22_locale/time_get/get_year/char/1.cc (test01): Parse 197
	as year 197AD instead of error.
	* testsuite/22_locale/time_get/get_year/char/5.cc (test01): Parse 1 as
	year 2001 instead of error.
	* testsuite/22_locale/time_get/get_year/char/6.cc: New test.
	* testsuite/22_locale/time_get/get_year/wchar_t/1.cc (test01): Parse
	197 as year 197AD instead of error.
	* testsuite/22_locale/time_get/get_year/wchar_t/5.cc (test01): Parse
	1 as year 2001 instead of error.
	* testsuite/22_locale/time_get/get_year/wchar_t/6.cc: New test.
2022-01-10 15:38:47 +01:00
Jonathan Wakely 68c2e9e923 libstdc++: Fix and simplify freestanding configuration [PR103866]
This fixes the --disable-hosted-libstdcxx build so that it works with
--without-headers. Currently you need to also use --with-newlib, which
is confusing for users who aren't actually using newlib.

The AM_PROG_LIBTOOL checks are currently skipped for --with-newlib and
--with-avrlibc builds, with this change they are also skipped when using
--without-headers.  It would be nice if using --disable-hosted-libstdcxx
automatically skipped those checks, but GLIBCXX_ENABLE_HOSTED comes too
late to make the AM_PROG_LIBTOOL checks depend on $is_hosted.

The checks for EOF, SEEK_CUR etc. cause the build to fail if there is no
<stdio.h> available.  Unlike most headers, which get a HAVE_FOO_H macro,
<stdio.h> is in autoconf's default includes, so every check tries to
include it unconditionally. This change skips those checks for
freestanding builds.

Similarly, the checks for <stdint.h> types done by GCC_HEADER_STDINT try
to include <stdio.h> and fail for --without-headers builds. This change
skips the use of GCC_HEADER_STDINT for freestanding. We can probably
stop using GCC_HEADER_STDINT entirely, since only one file uses the
gstdint.h header that is generated, and that could easily be changed to
use <stdint.h> instead. That can wait for stage 1.

We also need to skip the GLIBCXX_CROSSCONFIG stage if --without-headers
was used, since we don't have any of the functions it deals with.

The end result of the changes above is that it should not be necessary
for a --disable-hosted-libstdcxx --without-headers build to also use
--with-newlib.

Finally, compile libsupc++ with -ffreestanding when --without-headers is
used, so that <stdint.h> will use <gcc-stdint.h> instead of expecting it
to come from libc.

libstdc++-v3/ChangeLog:

	PR libstdc++/103866
	* acinclude.m4 (GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS): Do
	nothing for freestanding builds.
	(GLIBCXX_ENABLE_HOSTED): Define FREESTANDING_FLAGS.
	* configure.ac: Do not use AC_LIBTOOL_DLOPEN when configured
	with --without-headers.  Do not use GCC_HEADER_STDINT for
	freestanding builds.
	* libsupc++/Makefile.am (HOSTED_CXXFLAGS): Use -ffreestanding
	for freestanding builds.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2022-01-10 12:18:14 +00:00
Jonathan Wakely e54dda45f9 libstdc++: Add dg-timeout-factor to some more regex tests
I'm seeing these fail with tool_timeout=30 on a busy machine.

libstdc++-v3/ChangeLog:

	* testsuite/28_regex/algorithms/regex_replace/char/103664.cc:
	Add dg-timeout-factor directive.
	* testsuite/28_regex/basic_regex/84110.cc: Likewise.
	* testsuite/28_regex/basic_regex/ctors/char/other.cc: Likewise.
	* testsuite/28_regex/match_results/102667.cc: Likewise.
2022-01-10 12:18:14 +00:00
Jonathan Wakely e1b8a91e47 libstdc++: Update default -std option in manual
libstdc++-v3/ChangeLog:

	* doc/xml/manual/using.xml: Update documentation around default
	-std option.
	* doc/html/*: Regenerate.
2022-01-10 12:18:14 +00:00
Jonathan Wakely 4fde88e5dd libstdc++: Add -nostdinc++ for c++17 sources [PR100017]
When building a build!=host compiler, the just-built gcc can't be used
to build the target libstdc++ (because it is built for the host triplet,
not the build triplet). The top-level configure.ac sets up the build
flags for libstdc++ (and other "raw_cxx" libs) like this:

GCC_TARGET_TOOL(c++ for libstdc++, RAW_CXX_FOR_TARGET, CXX,
		[gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs],
		c++)

The -nostdinc++ flag is only used for the IN-TREE-TOOL, i.e. when using
the just-built gcc/xgcc compiler. This means that the cross-compiler
used to build libstdc++ will add its own libstdc++ headers to the
include path. That results in the #include <cfenv> in
src/c++17/floating_to_chars.cc and src/c++17/floating_from_chars.cc
doing #include_next <fenv.h> and finding the libstdc++ fenv.h wrapper
from the host compiler. Because that has the same include guard as the
<fenv.h> in the libstdc++ we're trying to build, we never reach the
underlying <fenv.h> from libc. That results in several errors of the
form:

error: 'fenv_t' has not been declared in '::'

The most correct fix would be to add -nostdinc++ to the
RAW_CXX_FOR_TARGET variable in configure.ac, or the
RAW_CXX_TARGET_EXPORTS variable in Makefile.tpl.

Another solution would be to make the libstdc++ <fenv.h> wrapper use
_GLIBCXX_INCLUDE_NEXT_C_HEADERS like our <stdlib.h> and other C header
wrappers.

For now though, the simplest and safest solution is to just add
-nostdinc++ to the CXXFLAGS used for src/c++17/*.cc, which is what this
does.

libstdc++-v3/ChangeLog:

	PR libstdc++/100017
	* src/c++17/Makefile.am (AM_CXXFLAGS): Add -nostdinc++.
	* src/c++17/Makefile.in: Regenerate.
2022-01-10 12:18:13 +00:00
GCC Administrator 3a5702df3f Daily bump. 2022-01-10 00:16:20 +00:00
Sandra Loosemore 57fe1f6ad3 Testsuite: Make dependence on -fdelete-null-pointer-checks explicit
nios2-elf target defaults to -fno-delete-null-pointer-checks, breaking
tests that implicitly depend on that optimization.  Add the option
explicitly on these tests.

2022-01-08  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/testsuite/
	* g++.dg/cpp0x/constexpr-compare1.C: Add explicit
	-fdelete-null-pointer-checks option.
	* g++.dg/cpp0x/constexpr-compare2.C: Likewise.
	* g++.dg/cpp0x/constexpr-typeid2.C: Likewise.
	* g++.dg/cpp1y/constexpr-94716.C: Likewise.
	* g++.dg/cpp1z/constexpr-compare1.C: Likewise.
	* g++.dg/cpp1z/constexpr-if36.C: Likewise.
	* gcc.dg/init-compare-1.c: Likewise.

	libstdc++-v3/
	* testsuite/18_support/type_info/constexpr.cc: Add explicit
	-fdelete-null-pointer-checks option.
2022-01-08 22:17:18 -08:00
GCC Administrator 11ce8d04f2 Daily bump. 2022-01-07 00:16:24 +00:00
Pavel I. Kryukov 52ebc2be09 libstdc++: Add self-merge check to std::forward_list::merge [PR103853]
This implements the proposed resolution of LWG 3088, so that x.merge(x)
is a no-op, consistent with std::list::merge.

Signed-off-by: Pavel I. Kryukov <pavel.kryukov@phystech.edu>

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

libstdc++-v3/ChangeLog:

	PR libstdc++/103853
	* include/bits/forward_list.tcc (forward_list::merge): Check for
	self-merge.
	* testsuite/23_containers/forward_list/operations/merge.cc: New test.
2022-01-06 14:56:48 +00:00
Jonathan Wakely ec12ddd1e7 libstdc++: Adjust friend declarations to work with Clang
I think this code is valid but it fails with Clang, possibly due to
https://llvm.org/PR38882

Qualifying the names makes it work for all compilers.

libstdc++-v3/ChangeLog:

	* include/bits/regex.h (basic_regex, match_results): Qualify
	name in friend declaration, to work around Clang bug.
2022-01-06 14:56:48 +00:00
Jonathan Wakely e19e2989c3 libstdc++: Increase timeout for pthread7-rope.cc test
This test spawns thousands of threads and so times out if the tests are
run with a low timeout value and the machine is busy.

libstdc++-v3/ChangeLog:

	* testsuite/ext/rope/pthread7-rope.cc: Add dg-timeout-factor.
2022-01-06 14:56:33 +00:00
Jonathan Wakely c83ecfbe74 libstdc++: Do not use std::isdigit in <charconv> [PR103911]
This avoids a potential race condition if std::setlocale is used
concurrently with std::from_chars.

libstdc++-v3/ChangeLog:

	PR libstdc++/103911
	* include/std/charconv (__from_chars_alpha_to_num): Return
	char instead of unsigned char. Change invalid return value to
	127 instead of using numeric trait.
	(__from_chars_alnum): Fix comment. Do not use std::isdigit.
	Change type of variable to char.
2022-01-06 14:56:12 +00:00
GCC Administrator 0fbefa25b3 Daily bump. 2022-01-06 00:16:32 +00:00
François Dumont e3ef832a9e libstdc++: Optimize operations on small size hashtable [PR 68303]
When hasher is identified as slow and the number of elements is limited in the
container use a brute-force loop on those elements to look for a given key using
the key_equal functor. For the moment the default threshold to consider the
container as small is 20.

libstdc++-v3/ChangeLog:

	PR libstdc++/68303
	* include/bits/hashtable_policy.h
	(_Hashtable_hash_traits<_Hash>): New.
	(_Hash_code_base<>::_M_hash_code(const _Hash_node_value<>&)): New.
	(_Hashtable_base<>::_M_key_equals): New.
	(_Hashtable_base<>::_M_equals): Use latter.
	(_Hashtable_base<>::_M_key_equals_tr): New.
	(_Hashtable_base<>::_M_equals_tr): Use latter.
	* include/bits/hashtable.h
	(_Hashtable<>::__small_size_threshold()): New, use _Hashtable_hash_traits.
	(_Hashtable<>::find): Loop through elements to look for key if size is lower
	than __small_size_threshold().
	(_Hashtable<>::_M_emplace(true_type, _Args&&...)): Likewise.
	(_Hashtable<>::_M_insert_unique(_Kt&&, _Args&&, const _NodeGenerator&)): Likewise.
	(_Hashtable<>::_M_compute_hash_code(const_iterator, const key_type&)): New.
	(_Hashtable<>::_M_emplace(const_iterator, false_type, _Args&&...)): Use latter.
	(_Hashtable<>::_M_find_before_node(const key_type&)): New.
	(_Hashtable<>::_M_erase(true_type, const key_type&)): Use latter.
	(_Hashtable<>::_M_erase(false_type, const key_type&)): Likewise.
	* src/c++11/hashtable_c++0x.cc: Include <bits/functional_hash.h>.
	* testsuite/util/testsuite_performance.h
	(report_performance): Use 9 width to display memory.
	* testsuite/performance/23_containers/insert_erase/unordered_small_size.cc:
	New performance test case.
2022-01-05 21:46:52 +01:00
Jonathan Wakely 6aa0859afa libstdc++: Fix overconstrained std::string constructor [PR103919]
The C++17 basic_string(const T&, size_t, size_t) constructor is
overconstrained, so it can't be used for a NTBS and a temporary string
gets constructed (potentially allocating memory). There is no
corresponding constructor taking an NTBS, so no need to disambiguate
from it. Accepting an NTBS avoids the temporary (and potential
allocation) and is what the standard requires.

libstdc++-v3/ChangeLog:

	PR libstdc++/103919
	* include/bits/basic_string.h (basic_string(const T&, size_t, size_t)):
	Relax constraints on string_view parameter.
	* include/bits/cow_string.h (basic_string(const T&, size_t, size_t)):
	Likewise.
	* testsuite/21_strings/basic_string/cons/char/103919.cc: New test.
2022-01-05 15:31:04 +00:00