Commit Graph

13403 Commits

Author SHA1 Message Date
GCC Administrator d156bb8702 Daily bump. 2022-03-22 00:16:44 +00:00
Jakub Jelinek e63ac860af libstdc++: Work around clang misdesign in time_get<>::get [PR104990]
Apparently clang has a -fgnuc-version= option which allows it to pretend
it is any GCC version the user likes.  It is already bad that it claims to
be GCC 4.2 compatible by default when it is not (various unimplemented
extensions at least), but this option is a horrible idea.

Anyway, this patch adds a hack for it.

2022-03-21  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/104990
	* include/bits/locale_facets_nonio.tcc (get): Don't check if do_get
	isn't overloaded if __clang__ is defined.
2022-03-21 11:02:04 +01:00
GCC Administrator 8ca61ad148 Daily bump. 2022-03-19 00:16:22 +00:00
Jonathan Wakely 7a42b1fa1a libstdc++: Simplify constraints for std::any construction [PR104242]
Partially revert r12-4190-g6da36b7d0e43b6f9281c65c19a025d4888a25b2d
because using __and_<..., is_copy_constructible<T>> when T is incomplete
results in an error about deriving from is_copy_constructible<T> when
that is incomplete. I don't know how to fix that, so this simply
restores the previous constraint which worked in this case (even though
I think it's technically undefined to use is_copy_constructible<T> with
incomplete T). This doesn't restore exactly what we had before, but uses
the is_copy_constructible_v and __is_in_place_type_v variable templates
instead of the ::value member.

libstdc++-v3/ChangeLog:

	PR libstdc++/104242
	* include/std/any (any(T&&)): Revert change to constraints.
	* testsuite/20_util/any/cons/104242.cc: New test.
2022-03-18 15:40:03 +00:00
Jonathan Wakely ac73c944ea libstdc++: Reduce header dependencies from PSTL headers [PR92546]
This avoids including the whole of <functional> in <algorithm>, as the
<pstl/glue_algorithm_defs.h> header only actually needs std::pair.

This also avoids including <iterator> in <pstl/utils.h>, which only
needs <type_traits>, std::bad_alloc, and std::terminate (which can be
repalced with std::__terminate). This matters less, because
<pstl/utils.h> is only included by the <pstl/*_impl.h> headers and they
all use <iterator> anyway, and are only included by <execution>.

libstdc++-v3/ChangeLog:

	PR libstdc++/92546
	* include/pstl/glue_algorithm_defs.h: Replace <functional> with
	<bits/stl_pair.h>.
	* include/pstl/utils.h: Replace <iterator> with <type_traits>.
	(__pstl::__internal::__except_handler): Use std::__terminate
	instead of std::terminate.
	* src/c++17/fs_path.cc: Include <array>.
	* testsuite/25_algorithms/adjacent_find/constexpr.cc: Include
	<functional>.
	* testsuite/25_algorithms/binary_search/constexpr.cc: Likewise.
	* testsuite/25_algorithms/clamp/constrained.cc: Likewise.
	* testsuite/25_algorithms/equal/constrained.cc: Likewise.
	* testsuite/25_algorithms/for_each/constrained.cc: Likewise.
	* testsuite/25_algorithms/includes/constrained.cc: Likewise.
	* testsuite/25_algorithms/is_heap/constexpr.cc: Likewise.
	* testsuite/25_algorithms/is_heap_until/constexpr.cc: Likewise.
	* testsuite/25_algorithms/is_permutation/constrained.cc: Include
	<iterator>.
	* testsuite/25_algorithms/is_sorted/constexpr.cc: Include
	<functional>.
	* testsuite/25_algorithms/is_sorted_until/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/lexicographical_compare/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/lexicographical_compare/constrained.cc:
	Likewise.
	* testsuite/25_algorithms/lexicographical_compare_three_way/1.cc:
	Include <array>.
	* testsuite/25_algorithms/lower_bound/constexpr.cc: Include
	<functional>.
	* testsuite/25_algorithms/max/constrained.cc: Likewise.
	* testsuite/25_algorithms/max_element/constrained.cc: Likewise.
	* testsuite/25_algorithms/min/constrained.cc: Likewise.
	* testsuite/25_algorithms/min_element/constrained.cc: Likewise.
	* testsuite/25_algorithms/minmax_element/constrained.cc:
	Likewise.
	* testsuite/25_algorithms/mismatch/constexpr.cc: Likewise.
	* testsuite/25_algorithms/move/93872.cc: Likewise.
	* testsuite/25_algorithms/move_backward/93872.cc: Include
	<iterator>.
	* testsuite/25_algorithms/nth_element/constexpr.cc: Include
	<functional>.
	* testsuite/25_algorithms/partial_sort/constexpr.cc: Likewise.
	* testsuite/25_algorithms/partial_sort_copy/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/search/constexpr.cc: Likewise.
	* testsuite/25_algorithms/search_n/constrained.cc: Likewise.
	* testsuite/25_algorithms/set_difference/constexpr.cc: Likewise.
	* testsuite/25_algorithms/set_difference/constrained.cc:
	Likewise.
	* testsuite/25_algorithms/set_intersection/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/set_intersection/constrained.cc:
	Likewise.
	* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc:
	Likewise.
	* testsuite/25_algorithms/set_union/constexpr.cc: Likewise.
	* testsuite/25_algorithms/set_union/constrained.cc: Likewise.
	* testsuite/25_algorithms/sort/constexpr.cc: Likewise.
	* testsuite/25_algorithms/sort_heap/constexpr.cc: Likewise.
	* testsuite/25_algorithms/transform/constrained.cc: Likewise.
	* testsuite/25_algorithms/unique/constexpr.cc: Likewise.
	* testsuite/25_algorithms/unique/constrained.cc: Likewise.
	* testsuite/25_algorithms/unique_copy/constexpr.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/constexpr.cc: Likewise.
	* testsuite/std/ranges/adaptors/elements.cc: Include <vector>.
	* testsuite/std/ranges/adaptors/lazy_split.cc: Likewise.
	* testsuite/std/ranges/adaptors/split.cc: Likewise.
2022-03-18 10:16:36 +00:00
GCC Administrator e9ea30165b Daily bump. 2022-03-18 00:16:27 +00:00
Jonathan Wakely 00df7ee447 libstdc++: Avoid including <algorithm> in <filesystem> [PR92546]
This only affects Windows, but reduces the preprocessed size of
<filesystem> significantly.

libstdc++-v3/ChangeLog:

	PR libstdc++/92546
	* include/bits/fs_path.h (path::make_preferred): Use
	handwritten loop instead of std::replace.
2022-03-17 17:51:54 +00:00
Jonathan Wakely 38ce448963 libstdc++: Rewrite __moneypunct_cache::_M_cache [PR104966]
GCC thinks the following can lead to a buffer overflow when __ns.size()
equals zero:

	  const basic_string<_CharT>& __ns = __mp.negative_sign();
	  _M_negative_sign_size = __ns.size();
	  __negative_sign = new _CharT[_M_negative_sign_size];
	  __ns.copy(__negative_sign, _M_negative_sign_size);

This happens because operator new might be replaced with something that
writes to this->_M_negative_sign_size and so the basic_string::copy call
could use a non-zero size to write to a zero-length buffer.

The solution suggested by Richi is to cache the size in a local variable
so that the compiler knows it won't be changed between the allocation
and the copy.

This commit goes further and rewrites the whole function to use RAII and
delay all modifications of *this until after all allocations have
succeeded. The RAII helper type caches the size and copies the string
and owns the memory until told to release it.

libstdc++-v3/ChangeLog:

	PR middle-end/104966
	* include/bits/locale_facets_nonio.tcc
	(__moneypunct_cache::_M_cache): Replace try-catch with RAII and
	make all string copies before any stores to *this.
2022-03-17 17:51:53 +00:00
Jonathan Wakely 78ef40ecdc libstdc++: Fix comment in testsuite utility
libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_character.h: Fix comment.
2022-03-17 12:23:56 +00:00
GCC Administrator 9fc8f278eb Daily bump. 2022-03-17 00:17:00 +00:00
Jonathan Wakely 2f26b26721 libstdc++: Fix symbol versioning for Solaris 11.3 [PR103407]
The new std::from_chars implementation means that those symbols are now
defined on Solaris 11.3, which lacks uselocale. They were not present in
gcc-11, but the linker script gives them the GLIBCXX_3.4.29 symbol
version because that is the version where they appeared for systems with
uselocale.

This makes the version for those symbols depend on whether uselocale is
available or not, so that they get version GLIBCXX_3.4.30 on targets
where they weren't defined in gcc-11.

In order to avoid needing separate ABI baseline files for Solaris 11.3
and 11.4, the ABI checker program now treats the floating-point
std::from_chars overloads as undesignated if they are not found in the
baseline symbols file. This means they can be left out of the SOlaris
baseline without causing the check-abi target to fail.

libstdc++-v3/ChangeLog:

	PR libstdc++/103407
	* config/abi/pre/gnu.ver: Make version for std::from_chars
	depend on HAVE_USELOCALE macro.
	* testsuite/util/testsuite_abi.cc (compare_symbols): Treat
	std::from_chars for floating-point types as undesignated if
	not found in the baseline symbols file.
2022-03-16 21:16:53 +00:00
Jonathan Wakely 5a4e208022 libstdc++: Ensure that std::from_chars is declared when supported
This adjusts the declarations in <charconv> to match when the definition
is present. This solves the issue that std::from_chars is present on
Solaris 11.3 (using fast_float) but was not declared in the header
(because the declarations were guarded by _GLIBCXX_HAVE_USELOCALE).

Additionally, do not define __cpp_lib_to_chars unless both from_chars
and to_chars are supported (which is only true for IEEE float and
double). We might still provide from_chars (via strtold) but if to_chars
isn't provided, we shouldn't define the feature test macro.

Finally, this simplifies some of the preprocessor checks in the bodies
of std::from_chars in src/c++17/floating_from_chars.cc and hoists the
repeated code for the strtod version into a new function template.

N.B. the long double overload of std::from_chars will always be defined
if the float and double overloads are defined. We can always use one of
strtold or fast_float's binary64 routines (although the latter might
produce errors for some long double values if they are not representable
as binary64).

libstdc++-v3/ChangeLog:

	* include/std/charconv (__cpp_lib_to_chars): Only define when
	both from_chars and to_chars are supported for floating-point
	types.
	(from_chars, to_chars): Adjust preprocessor conditions guarding
	declarations.
	* include/std/version (__cpp_lib_to_chars): Adjust condition to
	match <charconv> definition.
	* src/c++17/floating_from_chars.cc (from_chars_strtod): New
	function template.
	(from_chars): Simplify preprocessor checks and use
	from_chars_strtod when appropriate.
2022-03-16 16:06:29 +00:00
GCC Administrator 510613e76c Daily bump. 2022-03-15 00:16:49 +00:00
Jonathan Wakely 8f7b7c1495 libstdc++: Fix reading UTF-8 characters for 16-bit targets [PR104875]
The current code in read_utf8_code_point assumes that integer promotion
will create a 32-bit int, but that's not true for 16-bit targets like
msp430 and avr. This changes the intermediate variables used for each
octet from unsigned char to char32_t, so that (c << N) works correctly
when N > 8.

libstdc++-v3/ChangeLog:

	PR libstdc++/104875
	* src/c++11/codecvt.cc (read_utf8_code_point): Use char32_t to
	hold octets that will be left-shifted.
2022-03-14 13:08:02 +00:00
GCC Administrator 5e28be8966 Daily bump. 2022-03-11 00:16:39 +00:00
Jonathan Wakely a8db9b9043 libstdc++: Do not use fast_float for 16-bit size_t [PR104870]
The preprocessor condition for using fast_float should match the one in
the header, and require at least 32-bit size_t.

libstdc++-v3/ChangeLog:

	PR libstdc++/104870
	* src/c++17/floating_from_chars.cc: Check __SIZE_WIDTH__ >= 32
	before using fast_float.
2022-03-10 23:45:03 +00:00
Detlef Vollmann b5417a0ba7 libstdc++: Move closing brace outside #endif [PR104866]
libstdc++-v3/ChangeLog:

	PR libstdc++/104866
	* include/bits/this_thread_sleep.h: Fix order of #endif and
	closing brace of namespace.
2022-03-10 21:04:01 +00:00
Jonathan Wakely 73f3b8a53e libstdc++: Fix std::strong_order to handle NaN on VAX
I mistakenly believed that VAX floats do not support NaN, but with GCC
__builtin_isnan(__builtin_nan("")) is true. That means my previous
change to <compare> is wrong, because it fails to handle NaN.

When std::numeric_limits<floating-point-type>::is_iec559 is false, as on
VAX, the standard only requires an ordering that is consistent with the
ordering observed by comparison operators. With this change the ordering
is -NaN < numbers < +NaN, and there is no support for different NaN bit
patterns (as I'm not even sure if GCC supports any for VAX).

libstdc++-v3/ChangeLog:

	* libsupc++/compare (_Strong_order::_S_fp_cmp) [__vax__]:
	Handle NaN.
2022-03-10 14:25:46 +00:00
Jonathan Wakely cfaa2fac42 libstdc++: Support VAX floats in std::strong_order
The VAX float and double format does not support NaN, so the
std::partial_ordering returned by <=> will never be 'unordered'. We can
just use the partial_ordering value as the strong_ordering.

libstdc++-v3/ChangeLog:

	* libsupc++/compare (_Strong_ordering::_S_fp_cmp) [__vax__]: Use
	<=> comparison.
2022-03-10 11:49:00 +00:00
GCC Administrator 8cc4f9cd82 Daily bump. 2022-03-10 00:16:28 +00:00
Patrick Palka 65857caee8 libstdc++: Avoid implicit narrowing from uint128_t [PR104859]
We need to be explicit about narrowing conversions from uint128_t since,
on targets that lack __int128, this type is defined as an integer-class
type that is only _explicitly_ convertible to the builtin integer types.
This issue was latent until r12-7563-ge32869a17b788b made the frontend
correctly reject explicit conversion functions during (dependent)
copy-initialization.

	PR libstdc++/104859

libstdc++-v3/ChangeLog:

	* src/c++17/floating_to_chars.cc (__floating_to_chars_hex):
	Be explicit when narrowing the shifted effective_mantissa,
	since it may have an integer-class type.
2022-03-09 18:48:52 -05:00
GCC Administrator 8d038a841a Daily bump. 2022-03-09 00:16:29 +00:00
Jonathan Wakely 7cce7b1c3d libstdc++: Remove incorrect copyright notice from header
This file has the SGI copyright notice, but contains no code from
the SGI STL. It was entirely written by me in 2019, originally as part
of the <memory> header. When I extracted it into a new header I
accidentally copied across the SGI copyright, but that only applies to
some much older parts of <memory>.

libstdc++-v3/ChangeLog:

	* include/bits/uses_allocator_args.h: Remove incorrect copyright
	notice.
2022-03-08 12:53:04 +00:00
GCC Administrator e6533e2ebe Daily bump. 2022-03-08 00:16:32 +00:00
Jonathan Wakely 4cb935cb69 libstdc++: Use visibility pragmas instead of attributes [PR104807]
The _GLIBCXX_PSEUDO_VISIBILITY macro isn't defined until after including
os_defines.h, so we can't use _GLIBCXX_VISIBILITY early in c++config.
Replace the uses of that macro with #pragma visibility push(default)
instead.

libstdc++-v3/ChangeLog:

	PR libstdc++/104807
	* include/bits/c++config (__terminate, __glibcxx_assert_fail):
	Replace _GLIBCXX_VISIBILITY on function with visibility pragma.
	(__is_constant_evaluated): Add visibility pragma.
2022-03-07 15:10:29 +00:00
Rasmus Villemoes 0f0b428961 libstdc++: vxworks: remove stray <iostream> include
There doesn't seem to be any reason for this TU to include
<iostream>, and it causes errors when the resulting libstdc++ is used
on our VxWorks 5.5 target - presumably because now libstdc++ itself
contains an instance of std::ios_base::Init. Which should be mostly
harmless, but apparently isn't, and from a QoI viewpoint should
probably be avoided anyway.

libstdc++-v3/ChangeLog:

	* config/locale/vxworks/ctype_members.cc: Remove <iostream>
	  include.
2022-03-07 08:44:46 +01:00
GCC Administrator 762181c5d6 Daily bump. 2022-03-06 00:16:16 +00:00
Jonathan Wakely d3a757af21 libstdc++: Ensure __glibcxx_assert_fail has default visibility
This ensures there's no linker error if libstdc++ headers are included
following a pragma that sets hidden visibility.

Similarly for std::__terminate, which is always-inline so shouldn't
matter, but it's not wrong to do this anyway.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (__glibcxx_assert_fail): Add visibility
	attribute.
	(__terminate): Likewise.
2022-03-05 20:33:36 +00:00
GCC Administrator 8d96e14c1d Daily bump. 2022-03-05 00:16:31 +00:00
Jonathan Wakely 289f65d643 libstdc++: Fix -Wunused-local-typedefs warning in <compare>
libstdc++-v3/ChangeLog:

	* libsupc++/compare (strong_order::_S_fp_cmp): Move typedef
	inside #if condition.
2022-03-04 10:43:29 +00:00
GCC Administrator fc03ebdcea Daily bump. 2022-03-04 00:16:21 +00:00
Jonathan Wakely 5706a5db88 libstdc++: Use non-debug vector in constexpr test [PR104748]
The std::__debug::vector isn't usable in constant expressions, so this
test fails in debug mode. Until the debug vector is fixed we can just
make the test use the non-debug one.

libstdc++-v3/ChangeLog:

	PR libstdc++/104748
	* testsuite/std/ranges/adaptors/all.cc: Use non-debug vector for
	constexpr test.
2022-03-03 22:28:48 +00:00
Jonathan Wakely 64cdf49962 libstdc++: Fix test failure on AIX
This fixes a test failure due to a non-reserved name in an AIX system
header (included via <pthread.h>). That name clashes with one of the
names we check our own headers for, so skip checking that name on AIX.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc (func): Undef on AIX.
2022-03-03 22:25:44 +00:00
Jonathan Wakely 9805965e35 libstdc++: Implement std::strong_order for floating-point types [PR96526]
This removes a FIXME in <compare>, defining the total order for
floating-point types. I originally opened PR96526 to request a new
compiler built-in to implement this, but now that we have std::bit_cast
it can be done entirely in the library.

The implementation is based on the glibc definitions of totalorder,
totalorderf, totalorderl etc.

I think this works for all the types that satisfy std::floating_point
today, and should also work for the types expected to be added by P1467
except for std::bfloat16_t. It also supports some additional types that
don't currently satisfy std::floating_point, such as __float80, but we
probably do want that to satisfy the concept for non-strict modes.

libstdc++-v3/ChangeLog:

	PR libstdc++/96526
	* libsupc++/compare (strong_order): Add missing support for
	floating-point types.
	* testsuite/18_support/comparisons/algorithms/strong_order_floats.cc:
	New test.
2022-03-03 22:24:45 +00:00
GCC Administrator 12d4552e5e Daily bump. 2022-03-02 00:16:32 +00:00
Jonathan Wakely ad66b03b3c libstdc++: Fix -Wmaybe-uninitialized false positive [PR103984]
This fixes a false positive warning seen with LTO:

12/bits/regex_compiler.tcc:443:32: error: '__last_char._M_char' may be used uninitialized [-Werror=maybe-uninitialized]

Given that the std::regex code is not very efficient anyway, the
overhead of initializing this byte should be minimal.

libstdc++-v3/ChangeLog:

	PR middle-end/103984
	* include/bits/regex_compiler.h (_BracketMatcher::_M_char): Use
	default member initializer.
2022-03-01 15:25:39 +00:00
GCC Administrator 756a61851c Daily bump. 2022-02-25 00:16:20 +00:00
Jonathan Wakely 41cbcf53dc libstdc++: Fix cast in source_location::current() [PR104602]
This fixes a problem for Clang, which is going to return a non-void
pointer from __builtin_source_location(). The current definition of
std::source_location::current() converts that to void* and then has to
cast it back again in the body (which makes it invalid in a constant
expression). By using the actual type of the returned pointer, we avoid
the problematic cast for Clang.

libstdc++-v3/ChangeLog:

	PR libstdc++/104602
	* include/std/source_location (source_location::current): Use
	deduced type of __builtin_source_location().
2022-02-24 23:42:41 +00:00
GCC Administrator 2cfb33fc1e Daily bump. 2022-02-23 00:16:24 +00:00
Patrick Palka 5e1b17f038 libstdc++: Implement P2415R2 changes to viewable_range / views::all
This implements the wording changes in P2415R2 "What is a view?", which
is a DR for C++20.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (__detail::__is_initializer_list):
	Define.
	(viewable_range): Adjust as per P2415R2.
	* include/bits/ranges_cmp.h (__cpp_lib_ranges): Adjust value.
	* include/std/ranges (owning_view): Define as per P2415R2.
	(enable_borrowed_range<owning_view>): Likewise.
	(views::__detail::__can_subrange): Replace with ...
	(views::__detail::__can_owning_view): ... this.
	(views::_All::_S_noexcept): Sync with operator().
	(views::_All::operator()): Use owning_view instead of subrange
	as per P2415R2.
	* include/std/version (__cpp_lib_ranges): Adjust value.
	* testsuite/std/ranges/adaptors/all.cc (test06): Adjust now that
	views::all uses owning_view instead of subrange.
	(test08): New test.
	* testsuite/std/ranges/adaptors/lazy_split.cc (test09): Adjust
	now that rvalue non-view non-borrowed ranges are viewable.
	* testsuite/std/ranges/adaptors/split.cc (test06): Likewise.
2022-02-22 09:37:58 -05:00
GCC Administrator 0bdb049877 Daily bump. 2022-02-18 00:16:39 +00:00
Jonathan Wakely 12a88e6e20 libstdc++: Deprecate non-standard std::vector<bool>::insert(pos) [PR104559]
The SGI STL and pre-1998 drafts of the C++ standard had a default
argument for vector<bool>::insert(iterator, const bool&) which was
remove by N1051. The default argument is still present in libstdc++ for
some reason. There are no tests verifying it as an extension, so I don't
think it has been kept intentionally.

This removes the default argument but adds an overload without the
second parameter, and adds the deprecated attribute to it. This allows
any code using it to keep working (for now) but with a warning.

libstdc++-v3/ChangeLog:

	PR libstdc++/104559
	* doc/xml/manual/evolution.xml: Document deprecation.
	* doc/html/manual/api.html: Regenerate.
	* include/bits/stl_bvector.h (insert(const_iterator, const bool&)):
	Remove default argument.
	(insert(const_iterator)): New overload with deprecated attribute.
	* testsuite/23_containers/vector/bool/modifiers/insert/104559.cc:
	New test.
2022-02-17 23:44:25 +00:00
Jonathan Wakely 36100e0e95 libstdc++: Make std::error_code printer more robust
This attempts to implement a partial workaround for the GDB bug
https://sourceware.org/bugzilla/show_bug.cgi?id=28856 which causes GDB
to crash when printing a frame with a std::error_code argument.

By recognising the known error categories defined in the library and
hardcoding their names we do not need to call cat->name() on the
category.  This has the additional benefit of also working when
debugging a core file rather than a running process. For those known
categories we can also cast the int value to the corresponding error
code enum (e.g. future_errc) so that we show an enumerator instead of
just an integer.

For program-defined categories we just use the name of the dynamic type
to identify the category, and print the value as an integer. Once the
GDB bug is fixed and the virtual name() function can be called safely,
that would be preferable. For now it's better to have an imperfect
printer that doesn't crash GDB.

This rewritten StdErrorCodePrinter needs gdb.Value.dynamic_type, so is
only registered if that is supported, which means GDB 7.7 and later.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Replace
	code that call cat->name() on std::error_category objects.
	Identify known categories by symbol name and use a hardcoded
	name. Print error code values as enumerators where appopriate.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Adjust expected
	name of custom category. Check io_errc and future_errc errors.
2022-02-17 22:22:14 +00:00
GCC Administrator 875e493bf5 Daily bump. 2022-02-16 00:16:26 +00:00
Jonathan Wakely 6cfb7ffb65 libstdc++: Add missing constexpr to uses-allocator construction utilities [PR104542]
libstdc++-v3/ChangeLog:

	PR libstdc++/104542
	* include/bits/uses_allocator_args.h (make_obj_using_allocator)
	(uninitialized_construct_using_allocator): Add constexpr.
	* testsuite/20_util/uses_allocator/make_obj.cc: Check constexpr.
	* testsuite/20_util/uses_allocator/uninitialized_construct.cc: New test.
2022-02-15 12:49:34 +00:00
GCC Administrator 1f8a09d2f3 Daily bump. 2022-02-15 00:16:41 +00:00
Jonathan Wakely 3d50dede07 libstdc++: Fix stream extraction of IEEE128 long double [PR100912]
The std::__convert_from_v helper that formats double and long double
values into a char buffer was not being duplicated for the two long
double ABIs. This resulted in an ODR violation inside the library, where
some callers needed it to use snprintf to format __ibm128 values and
other callers needed it to use __snprintfieee128 to format __ieee128
values. The linker discarded one of the definitions, leaving one set of
callers using the wrong code.

This puts __convert_from_v in the __gnu_cxx_ieee128 inline namespace
when long double is __ieee128, so that there are two different
definitions of the function.

The std::money_put::__do_put overload for __ibm128 values needs a
different fix, because that is defined when long double is __ieee128 and
so would call the one in the inline namespace. That can be fixed by just
inlining the code directly into the function and using an asm alias to
call the right version of snprintf for the __ibm128 format. The code to
do that can be simpler than __convert_from_v because if we're defining
the ALT128_COMPAT symbols we know that we have a recent glibc and so we
can assume that uselocale and snprintf are supported.

libstdc++-v3/ChangeLog:

	PR libstdc++/100912
	* config/locale/gnu/c_locale.h (__convert_from_v): Use inline
	namespace for IEEE128 long double mode.
	* config/os/gnu-linux/ldbl-ieee128-extra.ver: Add new symbol
	version and export __gnu_cxx_ieee128::__convert_from_v.
	* include/bits/locale_facets_nonio.tcc (money_put::__do_put):
	Make __ibm128 overload use snprintf directly
	* testsuite/util/testsuite_abi.cc: Add new symbol version.
	Remove stable IEEE128/LDBL versions.
2022-02-14 17:19:08 +00:00
Jonathan Wakely 164a761a9f libstdc++: Use __cpp_concepts instead of custom macro [PR103891]
With the new value of __cpp_concepts required by P2493, we can test
whether the compiler supports conditionally trivial special members.
This allows us to remove the workaround that disables fully-constexpr
std::variant for Clang. Now it should work for non-GCC compilers (such
as future releases of Clang) that support conditionally trivial
destructors and define the new value of __cpp_concepts.

libstdc++-v3/ChangeLog:

	PR libstdc++/103891
	* include/bits/c++config (_GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS):
	Remove.
	* include/std/variant: Check feature test macros instead.
	* include/std/version: Likewise.
2022-02-14 13:03:31 +00:00
Jonathan Wakely 220d85fdf0 libstdc++: Fix typo in pragma
libstdc++-v3/ChangeLog:

	* testsuite/20_util/unsynchronized_pool_resource/allocate.cc:
	Fix typo.
2022-02-14 12:46:04 +00:00
Jonathan Wakely 8134156502 libstdc++: Fix std::to_chars for IEEE128 long double
The preprocessor check for _GLIBCXX_USE_FLOAT128 is the wrong condition,
because when the compiler is built with --with-long-double-format=ieee
configure determines that __float128 is the same as long double, and so
should not be used. But we do want the std::to_chars overloads for
__float128 in that case, because the floating_to_chars.cc file is built
with -mabi=ibmlongdouble and so the __float128 overloads are actually
the 'long double' ones for -mabi=ieeelongdouble code.

This fixes missing definitions of the __float128 overloads of
std::to_chars for --with-long-double-format=ieee builds. Without this,
there are symbols present in the --with-long-double-abi=ibm build which
are missing from the --with-long-double-abi=ieee build.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_to_chars.cc (FLOAT128_TO_CHARS): Depend on
	LONG_DOUBLE_ALT128_COMPAT instead of USE_FLOAT128.
2022-02-14 12:34:21 +00:00
GCC Administrator e8d68f0a45 Daily bump. 2022-02-12 00:16:23 +00:00
Jonathan Wakely 9a56779dbc libstdc++: Fix FAIL: 20_util/temporary_buffer.cc for C++14
The std::get_temporary_buffer function is deprecated since C++17, but
the test was expecting a warning for C++14 as well.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/temporary_buffer.cc: Fix dg-warning target
	selector.
2022-02-11 21:42:22 +00:00
Jonathan Wakely b02247346e libstdc++: Fix test failures at -O0
libstdc++-v3/ChangeLog:

	* testsuite/20_util/monotonic_buffer_resource/allocate.cc:
	Ignore -Walloc-larger-than warning.
	* testsuite/20_util/unsynchronized_pool_resource/allocate.cc:
	Likewise.
	* testsuite/29_atomics/atomic/cons/user_pod.cc: Compile with -O1
	to avoid linker error for __atomic_is_lock_free.
2022-02-11 21:41:43 +00:00
GCC Administrator a645583d4d Daily bump. 2022-02-11 00:16:25 +00:00
Thomas Rodgers b25a7c05f1 libstdc++: Strengthen memory order for atomic<T>::wait/notify
This changes the memory order used in the spin wait code to match
that of libc++.

libstdc++-v3/ChangeLog:
	* include/bits/atomic_wait.h (__waiter_base::_S_do_spin,
	__waiter_base::_S_do_spin_v): Change memory order from relaxed
	to acquire.
2022-02-10 10:14:36 -08:00
Jonathan Wakely 3e539985cc libstdc++: Add atomic_fetch_xor to <stdatomic.h>
This function (and the explicit memory over version) are present in both
C++ <atomic> and C <stdatomic.h>, so should be in C++ <stdatomic.h> too.
There is a library issue incoming for this, but the resolution is
obvious.

libstdc++-v3/ChangeLog:

	* include/c_compatibility/stdatomic.h (atomic_fetch_xor): Add
	using-declaration.
	(atomic_fetch_xor_explicit): Likewise.
	* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: Check
	arithmetic and logical operations for atomic_int.
2022-02-10 13:01:10 +00:00
Jonathan Wakely 3d5f4f76e6 libstdc++: Fix directory iterator build for newlib
When building for newlib HAVE_OPENAT and HAVE_UNLINKAT are (sometimes?)
defined, but <fcntl.h> is only included when HAVE_DIRENT_H is defined.
Since directory iterators are completely useless without <dirent.h>,
just override the HAVE_OPENAT and HAVE_UNLINKAT detection when we don't
have <dirent.h>.

libstdc++-v3/ChangeLog:

	* src/filesystem/dir-common.h (_GLIBCXX_HAVE_DIRFD): Undefine
	when <dirent.h> is not available.
	(_GLIBCXX_HAVE_UNLINKAT):  Likewise.
2022-02-10 13:01:10 +00:00
GCC Administrator 3adf509fe6 Daily bump. 2022-02-10 00:16:27 +00:00
Thomas Rodgers 4cf3c33981 libstdc++: Fix deadlock in atomic wait [PR104442]
This issue was observed as a deadlock in
29_atomics/atomic/wait_notify/100334.cc on vxworks. When a wait is
"laundered" (e.g. type T* does not suffice as a waitable address for the
platform's native waiting primitive), the address waited is that of the
_M_ver member of __waiter_pool_base, so several threads may wait on the
same address for unrelated atomic<T> objects. As noted in the PR, the
implementation correctly exits the wait for the thread whose data
changed, but not for any other threads waiting on the same address.

As noted in the PR the __waiter::_M_do_wait_v member was correctly exiting
but the other waiters were not reloading the value of _M_ver before
re-entering the wait.

Moving the spin call inside the loop accomplishes this, and is
consistent with the predicate accepting version of __waiter::_M_do_wait.

libstdc++-v3/ChangeLog:

	PR libstdc++/104442
	* include/bits/atomic_wait.h (__waiter::_M_do_wait_v): Move spin
	 loop inside do loop so that threads failing the wait, reload
	 _M_ver.
2022-02-09 12:30:51 -08:00
GCC Administrator 2a2fda2d9b Daily bump. 2022-02-09 00:16:24 +00:00
Jonathan Wakely 1ef6085f09 libstdc++: Simplify resource management in directory iterators
This replaces the _Dir constructor that takes ownership of an existing
DIR* resource with one that takes a _Dir_base rvalue instead. This means
a raw DIR* is never passed around, but is always owned by a _Dir_base
object.

libstdc++-v3/ChangeLog:

	* src/c++17/fs_dir.cc (_Dir(DIR*, const path&)): Change first
	parameter to _Dir_base&&.
	* src/filesystem/dir-common.h (_Dir_base(DIR*)): Remove.
	* src/filesystem/dir.cc (_Dir(DIR*, const path&)): Change first
	parameter to _Dir_base&&.
2022-02-08 21:04:14 +00:00
Jonathan Wakely 8dbb60b8df libstdc++: Add comment to acinclude.m4
libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY): Add comment about
	checking for CAS on correct word size.
2022-02-08 14:15:38 +00:00
Jonathan Wakely 61b783995f libstdc++: Adjust Filesystem TS test for Windows
The Filesystem TS isn't really supported for Windows, but the FAIL for
this test is just because it doesn't match what happens on Windows.

libstdc++-v3/ChangeLog:

	* testsuite/experimental/filesystem/operations/create_directories.cc:
	Adjust expected results for Windows.
2022-02-08 13:31:09 +00:00
Jonathan Wakely 5750952bec libstdc++: Fix filesystem::remove_all for Windows [PR104161]
The recursive_directory_iterator::__erase member was failing for
Windows, because the entry._M_type value is always file_type::none
(because _Dir_base::advance doesn't populate it for Windows) and
top.unlink uses fs::remove which sets an error using the
system_category. That meant that ec.value() was a Windows error code and
not an errno value, so the comparisons to EPERM and EISDIR failed.
Instead of depending on a specific Windows error code for attempting to
remove a directory, just use directory_entry::refresh() to query the
type first. This doesn't avoid the TOCTTOU races with directory
symlinks, but we can't avoid them on Windows without openat and
unlinkat, and creating symlinks requires admin privs on Windows anyway.

This also fixes the fs::remove_all(const path&) overload, which was
supposed to use the same logic as the other overload, but I forgot to
change it before my previous commit.

libstdc++-v3/ChangeLog:

	PR libstdc++/104161
	* src/c++17/fs_dir.cc (fs::recursive_directory_iterator::__erase):
	[i_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Refresh entry._M_type member,
	instead of checking for errno values indicating a directory.
	* src/c++17/fs_ops.cc (fs::remove_all(const path&)): Use similar
	logic to non-throwing overload.
	(fs::remove_all(const path&, error_code&)): Add comments.
	* src/filesystem/ops-common.h: Likewise.
2022-02-08 13:31:05 +00:00
GCC Administrator 3c1cbde16e Daily bump. 2022-02-05 00:16:31 +00:00
Jonathan Wakely 6e3419529d libstdc++: Fix std::filesystem build failure for Windows
The std::filesystem code needs to use posix::DIR not ::DIR, as that is
an alias for _WDIR on Windows.

libstdc++-v3/ChangeLog:

	* src/filesystem/dir-common.h (_Dir_base::openat): Change return
	type to use portable posix::DIR alias.
2022-02-04 23:56:29 +00:00
Jonathan Wakely 0d1aabb60e libstdc++: Allow Clang to use <stdatomic.h> before C++23
There is code that only expects to be compiled with clang++ and uses its
<stdatomic.h>, which works because Clang supports the _Atomic specifier
in C++. The addition  of <stdatomic.h> to libstdc++ broke this code, as
now it finds the C++ header instead, which is empty for any standard
mode before C++23.

This change allows that code to keep working as before, by forwarding to
clang's <stdatomic.h>.

libstdc++-v3/ChangeLog:

	* include/c_compatibility/stdatomic.h [__clang__]: Use
	#include_next <stdatomic.h>.
2022-02-04 19:51:26 +00:00
Jonathan Wakely da72e0fd20 libstdc++: Remove un-implementable noexcept from Filesystem TS operations
LWG 3014 removed these incorrect noexcept specifications from the C++17
std::filesystem operations. They are also incorrect on the experimental
TS versions and should be removed from them too.

libstdc++-v3/ChangeLog:

	* include/experimental/bits/fs_ops.h (fs::copy_file): Remove
	noexcept.
	(fs::create_directories): Likewise.
	(fs::remove_all): Likewise.
	* src/filesystem/ops.cc (fs::copy_file): Remove noexcept.
	(fs::create_directories): Likewise.
	(fs::remove_all): Likewise.
2022-02-04 19:51:26 +00:00
Jonathan Wakely ebf6175464 libstdc++: Fix filesystem::remove_all races [PR104161]
This fixes the remaining filesystem::remove_all race condition by using
POSIX openat to recurse into sub-directories and using POSIX unlinkat to
remove files. This avoids the remaining race where the directory being
removed is replaced with a symlink after the directory has been opened,
so that the filesystem::remove("subdir/file") resolves to "target/file"
instead, because "subdir" has been removed and replaced with a symlink.
The previous patch only fixed the case where the directory was replaced
with a symlink before we tried to open it, but it still used the full
(potentially compromised) path as an argument to filesystem::remove.

The first part of the fix is to use openat when recursing into a
sub-directory with recursive_directory_iterator. This means that opening
"dir/subdir" uses the file descriptor for "dir", and so is sure to open
"dir/subdir" and not "symlink/subdir". (The previous patch to use
O_NOFOLLOW already ensured we won't open "dir/symlink/" here.)

The second part of the fix is to use unlinkat for the remove_all
operation. Previously we used a directory_iterator to get the name of
each file in a directory and then used filesystem::remove(iter->path())
on that name. This meant that any checks (e.g. O_NOFOLLOW) done by the
iterator could be invalidated before the remove operation on that
pathname. The directory iterator contains an open DIR stream, which we
can use to obtain a file descriptor to pass to unlinkat. This ensures
that the file being deleted really is contained within the directory
we're iterating over, rather than using a pathname that could resolve to
some other file.

The filesystem::remove_all function previously used a (non-recursive)
filesystem::directory_iterator for each directory, and called itself
recursively for sub-directories. The new implementation uses a single
filesystem::recursive_directory_iterator object, and calls a new __erase
member function on that iterator. That new __erase member function does
the actual work of removing a file (or a directory after its contents
have been iterated over and removed) using unlinkat. That means we don't
need to expose the DIR stream or its file descriptor to the remove_all
function, it's still encapuslated by the iterator class.

It would be possible to add a __rewind member to directory iterators
too, to call rewinddir after each modification to the directory. That
would make it more likely for filesystem::remove_all to successfully
remove everything even if files are being written to the directory tree
while removing it. It's unclear if that is actually prefereable, or if
it's better to fail and report an error at the first opportunity.

The necessary APIs (openat, unlinkat, fdopendir, dirfd) are defined in
POSIX.1-2008, and in Glibc since 2.10. But if the target doesn't provide
them, the original code (with race conditions) is still used.

This also reduces the number of small memory allocations needed for
std::filesystem::remove_all, because we do not store the full path to
every directory entry that is iterated over. The new filename_only
option means we only store the filename in the directory entry, as that
is all we need in order to use openat or unlinkat.

Finally, rather than duplicating everything for the Filesystem TS, the
std::experimental::filesystem::remove_all implementation now just calls
std::filesystem::remove_all to do the work.

libstdc++-v3/ChangeLog:

	PR libstdc++/104161
	* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for dirfd
	and unlinkat.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/bits/fs_dir.h (recursive_directory_iterator): Declare
	remove_all overloads as friends.
	(recursive_directory_iterator::__erase): Declare new member
	function.
	* include/bits/fs_fwd.h (remove, remove_all): Declare.
	* src/c++17/fs_dir.cc (_Dir): Add filename_only parameter to
	constructor. Pass file descriptor argument to base constructor.
	(_Dir::dir_and_pathname, _Dir::open_subdir, _Dir::do_unlink)
	(_Dir::unlink, _Dir::rmdir): Define new member functions.
	(directory_iterator): Pass filename_only argument to _Dir
	constructor.
	(recursive_directory_iterator::_Dir_stack): Adjust constructor
	parameters to take a _Dir rvalue instead of creating one.
	(_Dir_stack::orig): Add data member for storing original path.
	(_Dir_stack::report_error): Define new member function.
	(__directory_iterator_nofollow): Move here from dir-common.h and
	fix value to be a power of two.
	(__directory_iterator_filename_only): Define new constant.
	(recursive_directory_iterator): Construct _Dir object and move
	into _M_dirs stack. Pass skip_permission_denied argument to first
	advance call.
	(recursive_directory_iterator::increment): Use _Dir::open_subdir.
	(recursive_directory_iterator::__erase): Define new member
	function.
	* src/c++17/fs_ops.cc (ErrorReporter, do_remove_all): Remove.
	(fs::remove_all): Use new recursive_directory_iterator::__erase
	member function.
	* src/filesystem/dir-common.h (_Dir_base): Add int parameter to
	constructor and use openat to implement nofollow semantics.
	(_Dir_base::fdcwd, _Dir_base::set_close_on_exec, _Dir_base::openat):
	Define new member functions.
	(__directory_iterator_nofollow): Move to fs_dir.cc.
	* src/filesystem/dir.cc (_Dir): Pass file descriptor argument to
	base constructor.
	(_Dir::dir_and_pathname, _Dir::open_subdir): Define new member
	functions.
	(recursive_directory_iterator::_Dir_stack): Adjust constructor
	parameters to take a _Dir rvalue instead of creating one.
	(recursive_directory_iterator): Check for new nofollow option.
	Construct _Dir object and move into _M_dirs stack. Pass
	skip_permission_denied argument to first advance call.
	(recursive_directory_iterator::increment): Use _Dir::open_subdir.
	* src/filesystem/ops.cc (fs::remove_all): Use C++17 remove_all.
2022-02-04 19:51:26 +00:00
Jonathan Wakely 27ba40559c libstdc++: Add suggestion to std::uncaught_exception() warning
We should use the SUGGEST macro for std::uncaught_exception()
deprecation warnings.

libstdc++-v3/ChangeLog:

	* include/bits/allocator.h: Qualify std::allocator_traits in
	deprecated warnings.
	* libsupc++/exception (uncaught_exception): Add suggestion to
	deprecated warning.
2022-02-04 15:26:59 +00:00
GCC Administrator 88944e1314 Daily bump. 2022-02-03 00:16:22 +00:00
Jonathan Wakely 2905e1af94 libstdc++: Fix -Wunused-variable warning for -fno-exceptions build
If _GLIBCXX_THROW_OR_ABORT expands to just __builtin_abort() then the
bool variable used in the filesystem_error constructor is unused. Mark
it as maybe_unused to there's no warning for -fno-exceptions builds.

libstdc++-v3/ChangeLog:

	* src/c++17/fs_dir.cc (fs::recursive_directory_iterator::pop):
	Add [[maybe_unused]] attribute.
	* src/filesystem/dir.cc (fs::recursive_directory_iterator::pop):
	Likewise.
2022-02-02 17:55:16 +00:00
Jonathan Wakely c123096cf1 libstdc++: Fix invalid instantiations in tests
These tests instantiate std::multiset and std::set with a type that has
no operator< so they should use a custom comparison function.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/multiset/operators/cmp_c++20.cc: Use
	custom comparison function for multiset.
	* testsuite/23_containers/set/operators/cmp_c++20.cc: Use custom
	comparison function for set.
2022-02-02 17:08:54 +00:00
Jonathan Wakely b229c51860 libstdc++: Fix link failure in _OutputIteratorConcept
The C++98-style concept check for output iterators causes a link
failure on mingw-w64, because the __val() member function isn't defined.
Change it to use a function pointer instead. That pointer is never set
to anything meaningful, but it doesn't matter as the __constraints()
function only has to be instantiated, it's never called.

We could refactor all of these to use unevaluated contexts (e.g. sizeof
of __decltype) so that we only check the expressions are well-formed,
without any codegen at all. Any improvements to these are very low
priority though.

libstdc++-v3/ChangeLog:

	* include/bits/boost_concept_check.h (_OutputIteratorConcept):
	Change member function to data member of function pointer type.
2022-02-02 16:30:51 +00:00
Martin Sebor 756eabacfc Declare std::array members with attribute const [PR101831].
Resolves:
PR libstdc++/101831 - Spurious maybe-uninitialized warning on std::array::size

libstdc++-v3/ChangeLog:

	PR libstdc++/101831
	* include/std/array (begin): Declare const member function attribute
	const.
	(end, rbegin, rend, size, max_size, empty, data): Same.
	* testsuite/23_containers/array/capacity/empty.cc: Add test cases.
	* testsuite/23_containers/array/capacity/max_size.cc: Same.
	* testsuite/23_containers/array/capacity/size.cc: Same.
	* testsuite/23_containers/array/iterators/begin_end.cc: New test.
2022-02-01 17:21:49 -07:00
GCC Administrator ae7e4af964 Daily bump. 2022-02-02 00:17:16 +00:00
Jonathan Wakely d98668eb06 libstdc++: Do not use dirent::d_type unconditionally
These new tests should not use the d_type member unless it's actually
present on the OS.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/iterators/error_reporting.cc: Use
	autoconf macro to check whether d_type is present.
	* testsuite/experimental/filesystem/iterators/error_reporting.cc:
	Likewise.
2022-02-02 00:01:43 +00:00
Jonathan Wakely 2dc2f41728 libstdc++: Add more tests for filesystem directory iterators
The PR 97731 test was added to verify a fix to the Filesystem TS code,
but we should also have the same test to avoid similar regressions in
the C++17 std::filesystem code.

Also add tests for directory_options::follow_directory_symlink

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/iterators/97731.cc: New test.
	* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
	Check follow_directory_symlink option.
	* testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc:
	Likewise.
2022-02-01 21:56:35 +00:00
Jonathan Wakely ec09a5335f libstdc++: Reset filesystem::recursive_directory_iterator on error
The standard requires directory iterators to become equal to the end
iterator value if they report an error. Some members functions of
filesystem::recursive_directory_iterator fail to do that.

libstdc++-v3/ChangeLog:

	* src/c++17/fs_dir.cc (recursive_directory_iterator::increment):
	Reset state to past-the-end iterator on error.
	(fs::recursive_directory_iterator::pop(error_code&)): Likewise.
	(fs::recursive_directory_iterator::pop()): Check _M_dirs before
	it might get reset.
	* src/filesystem/dir.cc (recursive_directory_iterator): Likewise,
	for the TS implementation.
	* testsuite/27_io/filesystem/iterators/error_reporting.cc: New test.
	* testsuite/experimental/filesystem/iterators/error_reporting.cc: New test.
2022-02-01 21:56:16 +00:00
Jonathan Wakely 90263a4830 libstdc++: Fix doxygen comment for filesystem::perms operators
libstdc++-v3/ChangeLog:

	* include/bits/fs_fwd.h (filesystem::perms): Fix comment.
2022-02-01 21:53:15 +00:00
Jonathan Wakely 19b8946dbd libstdc++: Improve config output for --enable-cstdio [PR104301]
Currently we just print "checking for underlying I/O to use... stdio"
unconditionally, whether configured to use stdio_pure or stdio_posix. We
should make it clear that the user's configure option chose the right
thing.

libstdc++-v3/ChangeLog:

	PR libstdc++/104301
	* acinclude.m4 (GLIBCXX_ENABLE_CSTDIO): Print different messages
	for stdio_pure and stdio_posix options.
	* configure: Regenerate.
2022-02-01 21:53:14 +00:00
Thomas Rodgers 07a971b28c Strengthen memory order for atomic<T>::wait/notify
This matches the memory order in libc++.

libstdc++-v3/ChangeLog:
	* include/bits/atomic_wait.h: Change memory order from
	Acquire/Release with relaxed loads to SeqCst+Release for
	accesses to the waiter's count.
2022-02-01 09:04:10 -08:00
GCC Administrator 1bb5266257 Daily bump. 2022-02-01 00:16:29 +00:00
Martin Liska c99a6eb015 Add mold detection for libs.
libatomic/ChangeLog:

	* acinclude.m4: Detect *_ld_is_mold and use it.
	* configure: Regenerate.

libgomp/ChangeLog:

	* acinclude.m4: Detect *_ld_is_mold and use it.
	* configure: Regenerate.

libitm/ChangeLog:

	* acinclude.m4: Detect *_ld_is_mold and use it.
	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	* acinclude.m4: Detect *_ld_is_mold and use it.
	* configure: Regenerate.
2022-01-31 09:46:44 +01:00
GCC Administrator c67ffc256d Daily bump. 2022-01-31 00:16:28 +00:00
Hans-Peter Nilsson baf98320ac libstdc++ testsuite: Don't run lwg3464.cc tests on simulators
These tests have always been failing for my autotester running a
cris-elf simulator; when unrestrained they take about 20 minutes each,
compared to the (doubled) timeout of 720 seconds, of a total 2h40min
for the whole of the libstdc++-v3 testsuite.  The tests cover counter
overflow and are already disabled for LP64 targets.

	* testsuite/27_io/basic_istream/get/char/lwg3464.cc: Don't run on
	simulator targets.
	* testsuite/27_io/basic_istream/get/wchar_t/lwg3464.cc: Likewise.
2022-01-30 17:51:02 +01:00
GCC Administrator 99f17e996f Daily bump. 2022-01-28 00:16:32 +00:00
Jonathan Wakely eae41b4d2c libstdc++: Prevent -Wstringop-overread warning in std::deque [PR100516]
The compiler warns about the loop in deque::_M_range_initialize because
it doesn't know that the number of nodes has already been correctly
sized to match the size of the input. Use __builtin_unreachable to tell
it that the loop will never be entered if the number of elements is
smaller than a single node.

libstdc++-v3/ChangeLog:

	PR libstdc++/100516
	* include/bits/deque.tcc (_M_range_initialize<ForwardIterator>):
	Add __builtin_unreachable to loop.
	* testsuite/23_containers/deque/100516.cc: New test.
2022-01-27 23:31:03 +00:00
Jonathan Wakely f21f22d1ba libstdc++: Avoid overflow in ranges::advance(i, n, bound)
When (bound - i) or n is the most negative value of its type, the
negative of the value will overflow. Instead of abs(n) >= abs(bound - i)
use n >= (bound - i) when positive and n <= (bound - i) when negative.
The function has a precondition that they must have the same sign, so
this works correctly. The precondition check can be moved into the else
branch, and simplified.

The standard requires calling ranges::advance(i, bound) even if i==bound
is already true, which is technically observable, but that's pointless.
We can just return n in that case. Similarly, for i!=bound but n==0 we
are supposed to call ranges::advance(i, n), but that's pointless. An LWG
issue to allow omitting the pointless calls is expected to be filed.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (ranges::advance): Avoid signed
	overflow. Do nothing if already equal to desired result.
	* testsuite/24_iterators/range_operations/advance_overflow.cc:
	New test.
2022-01-27 22:24:29 +00:00
Martin Liska 14f339894d libstdc++: fix typo in acinclude.m4.
PR libstdc++/104259

libstdc++-v3/ChangeLog:

	* acinclude.m4: Fix typo.
	* configure: Regenerate.
2022-01-27 15:34:06 +01:00
GCC Administrator e0b8716f53 Daily bump. 2022-01-26 00:16:38 +00:00
Jonathan Wakely 5c1f274e3e libstdc++: Avoid some more warnings [PR104019]
With -fno-exceptions we get a -Wmisleading-indentation warning for:

  if (cond)
    __try {}
    __catch (...) {}

This is because the __catch(...) expands to if (false), but is indented
as though it is controlled by the preceding 'if'. Surround it in braces.

The new make_shared<T[]> code triggers a bogus warning due to PR 61596,
which can be disabled with a pragma.

libstdc++-v3/ChangeLog:

	PR libstdc++/104019
	* include/bits/istream.tcc (basic_istream::sentry): Add braces
	around try-block.
	* include/bits/shared_ptr_base.h (_Sp_counted_array_base::_M_init):
	Add pragmas to disable bogus warnings from PR 61596.
2022-01-25 21:05:16 +00:00
Jonathan Wakely e20486d508 libstdc++: Define _GNU_SOURCE for secure_getenv on Cygwin [PR104217]
For GNU/Linux G++ defines _GNU_SOURCE automatically, but not for Cygwin.
This means secure_getenv is not declared by Cygwin's <stdlib.h>, even
though autoconf detected it is present in the library. Define it in the
source files that want to use secure_getenv.

libstdc++-v3/ChangeLog:

	PR libstdc++/104217
	* src/c++17/fs_ops.cc (_GNU_SOURCE): Define.
	* src/filesystem/dir.cc (_GNU_SOURCE): Define.
	* src/filesystem/ops.cc (_GNU_SOURCE): Define.
2022-01-25 21:05:16 +00:00
Jonathan Wakely c8bd4dc821 libstdc++: Avoid symlink race in filesystem::remove_all [PR104161]
This adds a new internal flag to the filesystem::directory_iterator
constructor that makes it fail if the path is a symlink that resolves to
a directory. This prevents filesystem::remove_all from following a
symlink to a directory, rather than deleting the symlink itself.

We can also use that new flag in recursive_directory_iterator to ensure
that we don't follow symlinks if the follow_directory_symlink option is
not set.

This also moves an error check in filesystem::remove_all after the while
loop, so that errors from the directory_iterator constructor are
reproted, instead of continuing to the filesystem::remove call below.

libstdc++-v3/ChangeLog:

	PR libstdc++/104161
	* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for
	fdopendir.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* src/c++17/fs_dir.cc (_Dir): Add nofollow flag to constructor
	and pass it to base class constructor.
	(directory_iterator): Pass nofollow flag to _Dir constructor.
	(fs::recursive_directory_iterator::increment): Likewise.
	* src/c++17/fs_ops.cc (do_remove_all): Use nofollow option for
	directory_iterator constructor. Move error check outside loop.
	* src/filesystem/dir-common.h (_Dir_base): Add nofollow flag to
	constructor and when it's set use ::open with O_NOFOLLOW and
	O_DIRECTORY.
	* src/filesystem/dir.cc (_Dir): Add nofollow flag to constructor
	and pass it to base class constructor.
	(directory_iterator): Pass nofollow flag to _Dir constructor.
	(fs::recursive_directory_iterator::increment): Likewise.
	* src/filesystem/ops.cc (remove_all): Use nofollow option for
	directory_iterator constructor. Move error check outside loop.
2022-01-25 21:05:15 +00:00
GCC Administrator 0c940703f0 Daily bump. 2022-01-24 00:16:28 +00:00
Jonathan Wakely 51631875a2 libstdc++: Fix std::spanstream move assignment [PR104032]
libstdc++-v3/ChangeLog:

	PR libstdc++/104032
	* include/std/spanstream (basic_spanbuf(basic_spanbuf&&)): Use
	mem-initializer for _M_buf.
	(basic_spanbuf::Operator=(basic_spanbuf&&)): Fix ill-formed
	member access.
	* testsuite/27_io/spanstream/2.cc: New test.
2022-01-23 22:48:33 +00:00
Jonathan Wakely 416b6fc748 libstdc++: Use fast_float for long double if it uses binary64 format
We can use the new from_chars implementation when long double and double
have the same representation.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_from_chars.cc (USE_STRTOD_FOR_FROM_CHARS):
	Define macro for case where std::from_chars is implemented in
	terms of strtod, strtof or strtold.
	(buffer_resource, valid_fmt, find_end_of_float, pattern)
	(from_chars_impl, make_result, reserve_string): Do not define
	unless USE_STRTOD_FOR_FROM_CHARS is defined.
	(from_chars): Define when at least one of USE_LIB_FAST_FLOAT and
	USE_STRTOD_FOR_FROM_CHARS is defined, instead of
	_GLIBCXX_HAVE_USELOCALE. Use fast_float for long double when it
	is binary64.
2022-01-23 22:47:00 +00:00
Jonathan Wakely 084680db9a libstdc++: Restore support for unordered_map<const T, ...> [PR104174]
I broke this unintentionally in r12-4259.

libstdc++-v3/ChangeLog:

	PR libstdc++/104174
	* include/bits/hashtable_policy.h (_Map_base): Add partial
	specialization for maps with const key types.
	* testsuite/23_containers/unordered_map/104174.cc: New test.
2022-01-23 22:47:00 +00:00
Jonathan Wakely 2d8a9ad4a9 libstdc++: Fix aliasing violation in std::shared_ptr [PR104019]
The non-atomic store that sets both reference counts to zero uses a
type-punned pointer, which has undefined behaviour. We could use memset
to write 8 bytes, but we don't actually need it to be a single store
anyway. No other thread can observe the values, that's why it's safe to
use non-atomic stores in the first place. So we can just set each count
to zero.

With -fstore-merging (which is enabled by default at -O2) GCC produces
the same code for this as for memset or the type punned store. Clang
does that store merging even at -O1.

libstdc++-v3/ChangeLog:

	PR libstdc++/104019
	* include/bits/shared_ptr_base.h (_Sp_counted_base<>::_M_release):
	Set members to zero without type punning.
2022-01-23 22:47:00 +00:00
GCC Administrator 9dd443578f Daily bump. 2022-01-22 00:16:26 +00:00
Jonathan Wakely 45cae5b639 libstdc++: Fix typo in comment
libstdc++-v3/ChangeLog:

	* testsuite/20_util/shared_ptr/cons/array.cc: Fix comment.
2022-01-21 16:07:34 +00:00
Jonathan Wakely b8806796ec libstdc++: Ensure all feature test macros have type long [PR87193]
This defines all the __cpp_lib_xxx macros as type long, as required by
the standard. We had an inconsistent mix of int and long, sometimes even
for the same macro name.

The __cpp_lib_experimental_xxx macros are left as type int, because
that's what it says in the relevant TS specs.

libstdc++-v3/ChangeLog:

	PR libstdc++/87193
	PR libstdc++/104019
	* include/bits/alloc_traits.h (__cpp_lib_allocator_traits_is_always_equal):
	Define as type long.
	* include/bits/allocator.h (__cpp_lib_incomplete_container_elements):
	Likewise.
	* include/bits/basic_string.h (__cpp_lib_string_udls): Likewise.
	* include/bits/chrono.h (__cpp_lib_chrono): Likewise.
	(__cpp_lib_chrono_udls): Likewise.
	* include/bits/move.h (__cpp_lib_addressof_constexpr): Likewise.
	* include/bits/node_handle.h (__cpp_lib_node_extract): Likewise.
	* include/bits/range_access.h (__cpp_lib_nonmember_container_access):
	Likewise.
	* include/bits/shared_ptr.h (__cpp_lib_enable_shared_from_this):
	Likewise.
	* include/bits/stl_algo.h (__cpp_lib_clamp): Likewise.
	(__cpp_lib_sample): Likewise.
	* include/bits/stl_algobase.h (__cpp_lib_robust_nonmodifying_seq_ops):
	Likewise.
	* include/bits/stl_function.h (__cpp_lib_transparent_operators):
	Likewise.
	* include/bits/stl_iterator.h (__cpp_lib_make_reverse_iterator):
	Likewise.
	* include/bits/stl_map.h (__cpp_lib_map_try_emplace):
	Likewise.
	* include/bits/stl_tree.h (__cpp_lib_generic_associative_lookup):
	Likewise.
	* include/bits/unique_ptr.h (__cpp_lib_make_unique):
	Likewise.
	* include/bits/unordered_map.h (__cpp_lib_unordered_map_try_emplace):
	Likewise.
	* include/c_global/cmath (__cpp_lib_hypot): Likewise.
	* include/c_global/cstddef (__cpp_lib_byte): Likewise.
	* include/std/atomic (__cpp_lib_atomic_is_always_lock_free):
	Likewise.
	* include/std/complex (__cpp_lib_complex_udls): Likewise.
	* include/std/filesystem (__cpp_lib_filesystem): Likewise.
	* include/std/functional (__cpp_lib_not_fn): Likewise.
	(__cpp_lib_boyer_moore_searcher): Likewise.
	* include/std/iomanip (__cpp_lib_quoted_string_io): Likewise.
	* include/std/mutex (__cpp_lib_scoped_lock): Likewise.
	* include/std/numeric (__cpp_lib_gcd_lcm): Likewise.
	(__cpp_lib_gcd, __cpp_lib_lcm): Likewise.
	* include/std/tuple (__cpp_lib_apply): Likewise.
	(__cpp_lib_make_from_tuple): Likewise.
	* include/std/type_traits (__cpp_lib_integral_constant_callable)
	(__cpp_lib_bool_constant, __cpp_lib_logical_traits)
	(__cpp_lib_is_null_pointer, __cpp_lib_transformation_trait_aliases)
	(__cpp_lib_result_of_sfinae, __cpp_lib_void_t)
	(__cpp_lib_is_swappable, __cpp_lib_is_invocable)
	(__cpp_lib_has_unique_object_representations)
	(__cpp_lib_is_aggregate): Likewise.
	* include/std/version: Likewise.
	* libsupc++/new (__cpp_lib_launder): Likewise.
2022-01-21 16:07:34 +00:00
Jonathan Wakely 2da1ef06ff libstdc++: Fix condition for __cpp_lib_shared_ptr_arrays
I changed the preprocessor condition from <= to < in r12-6574 which
meant the macro was not defined by <version> for C++17.

libstdc++-v3/ChangeLog:

	* include/std/version (__cpp_lib_shared_ptr_arrays): Fix
	condition for C++17 definition.
2022-01-21 16:07:33 +00:00
Jonathan Wakely 7d47aae7cd libstdc++: Fix constexpr constructor for atomic<shared_ptr<T>>
libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (_Sp_atomic::_Atomic_count):
	Add constexpr.
	(_Sp_atomic::_M_ptr): Add default member-initializer.
	* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc:
	Check constant initialization.
	* testsuite/20_util/weak_ptr/atomic_weak_ptr.cc: Likewise.
2022-01-21 13:21:27 +00:00
GCC Administrator 5fa55d55ab Daily bump. 2022-01-21 00:16:28 +00:00
Jonathan Wakely 109f8af3d3 libstdc++: Use Clang attribute instead of __constinit
Clang doesn't support the __constinit extension that we use pre-C++20,
but it does have its own equivalent attribute that can be used instead.

This makes it a little easier to use Clang to build libstdc++ (which
isn't supported. but is sometimes attempted for esoteric targets).

libstdc++-v3/ChangeLog:

	* src/c++11/cxx11-ios_failure.cc (__constinit): Define as
	equivalent attribute for Clang.
	* src/c++11/future.cc (__constinit): Likewise.
	* src/c++11/system_error.cc (__constinit): Likewise.
	* src/c++17/memory_resource.cc (__constinit): Likewise.
2022-01-20 12:29:29 +00:00
Jonathan Wakely 5929f253fc libstdc++: Only add valid -L paths to testsuite linker options
The MacOS linker warns about -L arguments that don't exist, which causes
all tests to fail for the defauly configuration (because libbacktrace
isn't built).

libstdc++-v3/ChangeLog:

	* scripts/testsuite_flags.in: Only add src/filesystem/.libs and
	src/libbacktrace/.libs to LDFLAGS if those directories exist.
2022-01-20 12:29:29 +00:00
GCC Administrator fe1ad14165 Daily bump. 2022-01-20 00:16:54 +00:00
Jonathan Wakely fe3e978027 libstdc++: Remove -gdwarf-4 from flags for debug library
The default is -gdwarf-5 now, so this is hurting rather than improving
things.

libstdc++-v3/ChangeLog:

	* configure.ac (GLIBCXX_ENABLE_DEBUG_FLAGS): Remove -gdwarf-4
	from default flags.
	* configure: Regenerate.
2022-01-19 19:31:00 +00:00
Jonathan Wakely f5c50748f3 libstdc++: Include <stddef.h> for size_t and ptrdiff_t [PR104123]
libstdc++-v3/ChangeLog:

	PR libstdc++/104123
	* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: Include
	<stddef.h>.
2022-01-19 17:40:37 +00:00
Jonathan Wakely 6a26ad6736 libstdc++: Fix libbacktrace build files
This makes it possible to combine --enable-libstdcxx-debug with
--enable-libstdcxx-backtrace, by adding a rule to src/Makefile to copy
the backtrace-supported.h header into the src/debug/libbacktrace
directory.

Add libbacktrace path to testsuite flags so the tests can link without
having the library installed.

Also fix some warnings when running automake for the libbacktrace
makefile.

Use a per-library CPPFLAGS variable to fix:

src/libbacktrace/Makefile.am:38: warning: AM_CPPFLAGS multiply defined in condition TRUE ...
fragment.am:43: ... 'AM_CPPFLAGS' previously defined here
src/libbacktrace/Makefile.am:32:   'fragment.am' included from here

Create symlinks to the libbacktrace sources to fix:

src/libbacktrace/Makefile.am:55: warning: source file '../../../libbacktrace/atomic.c' is in a subdirectory,
src/libbacktrace/Makefile.am:55: but option 'subdir-objects' is disabled

libstdc++-v3/ChangeLog:

	* scripts/testsuite_flags.in: Add src/libbacktrace/.libs to
	linker search paths.
	* src/Makefile.am: Fix src/debug/libbacktrace build.
	* src/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.am: Use per-library CPPFLAGS
	variable. Use symlinks for the source files.
	* src/libbacktrace/Makefile.in: Regenerate.
2022-01-19 14:23:13 +00:00
Matthias Kretz 39f581028c libstdc++: Fix for non-constexpr math_errhandling
Use SFINAE magic to support: "It is unspecified whether math_errhandling
is a macro or an identifier with external linkage." [C Standard]

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h (__floating_point_flags): Do
	not rely on math_errhandling to expand to a constant expression.
2022-01-19 13:45:58 +01:00
Jonathan Wakely 9c186493a7 libstdc++: Update documentation for C++17 deprecations
libstdc++-v3/ChangeLog:

	* doc/xml/manual/evolution.xml: Document deprecations.
	* doc/xml/manual/status_cxx2017.xml: Update status.
	* doc/html/*: Regenerate.
2022-01-19 00:58:26 +00:00
Jonathan Wakely a68080a121 libstdc++: Fix deprecated attribute for std::get_temporary_buffer
This was deprecated in C++17, not C++14.

libstdc++-v3/ChangeLog:

	* include/bits/stl_tempbuf.h (get_temporary_buffer): Change
	_GLIBCXX14_DEPRECATED to _GLIBCXX17_DEPRECATED.
2022-01-19 00:58:25 +00:00
Jonathan Wakely 72ce3fd2c7 libstdc++: Remove unused std::pair helper function
This function is no longer used since r12-6691 and can be removed.

libstdc++-v3/ChangeLog:

	* include/bits/stl_pair.h (_PCC::_DeprConsPair): Remove unused
	function.
2022-01-19 00:58:25 +00:00
Jonathan Wakely c3861f7985 libstdc++: Fix std::atomic<std::shared_ptr<T>> for AIX [PR104101]
This fixes an on AIX.

The lock function currently just spins, which should be changed to use
back-off, and maybe then _M_val.wait(__current) when supported.

libstdc++-v3/ChangeLog:

	PR libstdc++/104101
	* include/bits/shared_ptr_atomic.h (_Sp_atomic::_Atomic_count::lock):
	Only use __thread_relax if __cpp_lib_atomic_wait is defined.
2022-01-19 00:58:21 +00:00
GCC Administrator 7a761ae658 Daily bump. 2022-01-19 00:16:32 +00:00
Jonathan Wakely fe3ed885cd libstdc++: Limit new basic_string(nullptr_t) constructor to C++23 [PR104099]
The new deleted constructors added by P2166R1 are a breaking change,
making previously valid code ill-formed in C++23. As a result, they
should only be defined for C++23 and not for C++11 and up.

libstdc++-v3/ChangeLog:

	PR libstdc++/104099
	* include/bits/basic_string.h (basic_string(nullptr_t)): Only
	define for C++23.
	(operator=(nullptr_t)): Likewise.
	* include/bits/cow_string.h: Likewise.
	* include/std/string_view (basic_string_view(nullptr_t)):
	Likewise.
	* testsuite/21_strings/basic_string/cons/char/nullptr.cc: Adjust
	expected error. Add examples that become ill-formed in C++23.
	* testsuite/21_strings/basic_string_view/cons/char/nonnull.cc:
	Adjust expected errors.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/nonnull.cc:
	Likewise.
2022-01-18 20:41:46 +00:00
Jonathan Wakely e13e95bd27 libstdc++: Use __cpp_lib_concepts in std::reverse_iterator [PR104098]
We should not assume that std::iter_value_t etc. are defined
unconditionally for C++20 mode.

libstdc++-v3/ChangeLog:

	PR libstdc++/104098
	* include/bits/stl_iterator.h (reverse_iterator): Check
	__cpp_lib_concepts instead of __cplusplus.
2022-01-18 16:31:03 +00:00
Jonathan Wakely 302343d8dd libstdc++: Fix ambiguous std::pair constructors [PR101124]
The deprecated non-standard std::pair constructors that allow
constructing std::pair<move-only-type, pointer-type> from an rvalue and
a literal zero where not sufficiently constrained. They were viable when
constructing std::pair<copyable-type, pointer-type>, and that case
should work fine using the standard constructors.

Replace the constraints on the non-standard constructors so they are
only viable in cases that should actually be ill-formed according to the
standard.

Also rename __null_ptr_constant to __zero_as_null_pointer_constant so it
matches the name of the -Wzero-as-null-pointer-constant warning. Also
make the text of the deprecated warning describe the problem in more
detail.

libstdc++-v3/ChangeLog:

	PR libstdc++/101124
	* include/bits/stl_pair.h (pair): Adjust constraints on
	deprecated constructors accepting literal zero as null pointer
	constant. Improve wording of deprecated attribute.
	* testsuite/20_util/pair/cons/99957.cc: Check that deprecated
	constructors do not cause ambiguities for copyable types.
2022-01-18 16:31:03 +00:00
Jonathan Wakely 50bc6e463b libstdc++: Fix suggested alternative to std::ptr_fun
libstdc++-v3/ChangeLog:

	* include/bits/stl_function.h (ptr_fun): Fix suggestion for
	non-deprecated alternative.
2022-01-18 16:31:02 +00:00
Tom Honermann 0e4e4b37d9 libstdc++: Declare std::c8rtomb and std::mbrtoc8 if provided by the C library
This patch completes implementation of the C++20 proposal P0482R6 [1] by
adding declarations of std::c8rtomb() and std::mbrtoc8() in <cuchar> if
provided by the C library in <uchar.h>.

This patch addresses feedback provided in response to a previous patch
submission [2].

Autoconf changes determine if the C library declares c8rtomb and mbrtoc8
at global scope when uchar.h is included and compiled with either
-fchar8_t or -std=c++20. New _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T
and _GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20 configuration macros
reflect the probe results. The <cuchar> header declares these functions
in the std namespace only if available and the _GLIBCXX_USE_CHAR8_T
configuration macro is defined (by default it is defined if the C++20
__cpp_char8_t feature test macro is defined)

Patches to glibc to implement c8rtomb and mbrtoc8 have been submitted [3].

New tests validate the presence of these declarations. The tests pass
trivially if the C library does not provide these functions. Otherwise
they ensure that the functions are declared when <cuchar> is included
and either -fchar8_t or -std=c++20 is enabled.

1]: WG21 P0482R6
      "char8_t: A type for UTF-8 characters and strings (Revision 6)"
      https://wg21.link/p0482r6

[2]: [PATCH] C++ P0482R6 char8_t: declare std::c8rtomb and std::mbrtoc8
if provided by the C library
      https://gcc.gnu.org/pipermail/libstdc++/2021-June/052685.html

[3]: "C++20 P0482R6 and C2X N2653"
      [Patch 0/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135061.html
      [Patch 1/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135062.html
      [Patch 2/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135063.html
      [Patch 3/3]:
https://sourceware.org/pipermail/libc-alpha/2022-January/135064.html

libstdc++-v3/ChangeLog:

	* acinclude.m4: Define config macros if uchar.h provides
	c8rtomb() and mbrtoc8().
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* include/c_compatibility/uchar.h (c8rtomb, mbrtoc8): Define.
	* include/c_global/cuchar (c8rtomb, mbrtoc8): Likewise.
	* include/c_std/cuchar (c8rtomb, mbrtoc8): Likewise.
	* testsuite/21_strings/headers/cuchar/functions_std_cxx20.cc:
	New test.
	* testsuite/21_strings/headers/cuchar/functions_std_fchar8_t.cc:
	New test.
2022-01-18 16:31:02 +00:00
Jonathan Wakely d7f2a09e98 libstdc++: Define <stdatomic.h> for C++23
This adds the C++23 <stdatomic.h> header, as proposed by P0943R6, for
compatibility with C code.

There are still some ABI differences between atomic_xxx in C and C++
std::atomic_xxx in C++, so this only provides source compatibility, not
binary compatibility.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Install new header.
	* include/Makefile.in: Regenerate.
	* include/c_compatibility/stdatomic.h: New file.
	* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc: New test.
2022-01-18 16:31:02 +00:00
Jonathan Wakely 8f6b62e0f0 libstdc++: Use GCC's predefined macro for endianness [PR104080]
Instead of hardcoded preprocessor conditionals with explicit target
checks, just rely on the fact that __BYTE_ORDER__ is always defined by
GCC.

libstdc++-v3/ChangeLog:

	PR libstdc++/104080
	* src/c++17/fast_float/LOCAL_PATCHES: Update.
	* src/c++17/fast_float/fast_float.h (FASTFLOAT_IS_BIG_ENDIAN):
	Define in terms of __BYTE_ORDER__.
2022-01-18 10:03:16 +00:00
Jonathan Wakely 97b9236976 libstdc++: Fix deduction failure for std::min call [PR104080]
libstdc++-v3/ChangeLog:

	PR libstdc++/104080
	* src/c++17/fast_float/LOCAL_PATCHES: UPDATE.
	* src/c++17/fast_float/fast_float.h (round): Use explicit
	template argument list for std::min.
2022-01-18 09:53:30 +00:00
Jonathan Wakely ac358eef7a libstdc++: Update status tables in manual
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2017.xml: Update C++17 status.
	* doc/xml/manual/status_cxx2020.xml: Use 12.1 instead of 12 for
	upcoming release.
	* doc/html/manual/status.html: Regenerate.
2022-01-18 09:51:02 +00:00
Jonathan Wakely 5f3c0ee908 libstdc++: Improve comments describing --enable-fully-dynamic-string
libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING): Improve
	comments.
	* configure: Regenerate.
2022-01-18 09:51:02 +00:00
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
Jonathan Wakely 3633cc5428 libstdc++: Implement P1328 "Making std::type_info::operator== constexpr"
This feature is present in the C++23 draft.

With Jakub's recent front-end changes we can implement constexpr
equality by comparing the addresses of std::type_info objects. We do not
need string comparisons, because for constant evaluation cases we know
we aren't dealing with std::type_info objects defined in other
translation units.

The ARM EABI requires that the type_info::operator== function can be
defined out-of-line (and suggests that should be the default), but to be
a constexpr function it must be defined inline (at least for C++23
mode). To meet these conflicting requirements we make the inline version
of operator== call a new __equal function when called at runtime. That
is an alias for the non-inline definition of operator== defined in
libsupc++.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export new symbol for
	ARM EABI.
	* include/bits/c++config (_GLIBCXX23_CONSTEXPR): Define.
	* include/std/version (__cpp_lib_constexpr_typeinfo): Define.
	* libsupc++/tinfo.cc: Add #error to ensure non-inline definition
	is emitted.
	(type_info::__equal): Define alias symbol.
	* libsupc++/typeinfo (type_info::before): Combine different
	implementations into one.
	(type_info::operator==): Likewise. Use address equality for
	constant evaluation. Call __equal for targets that require the
	definition to be non-inline.
	* testsuite/18_support/type_info/constexpr.cc: New test.
2022-01-05 14:43:01 +00:00
Jonathan Wakely 096228d84e libstdc++: Improvements to standard error category objects (part deux)
In r12-3860 the error categories in <system_error> were made final and
immortal, but I missed the categories for <future> and <ios>. This makes
the same changes to those.

libstdc++-v3/ChangeLog:

	* src/c++11/cxx11-ios_failure.cc (io_error_category): Define
	class and virtual functions as 'final'.
	(io_category_instance): Use constinit union to make the object
	immortal.
	* src/c++11/future.cc (future_error_category): Define class and
	virtual functions as 'final'.
	(future_category_instance): Use constinit union.
2022-01-05 14:17:51 +00:00
Jonathan Wakely 1918067e2d libstdc++: Fix std::error_code pretty printer for versioned namespace
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Strip
	versioned namespace from the type name that is printed.
2022-01-05 14:17:50 +00:00
Jonathan Wakely 7a2f2d91aa libstdc++: Add pretty printer for std::regex internals
This helps visualize the NFA states in a std::regex.  It probably isn't
very useful for users, but helps when working on the implementation.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdRegexStatePrinter): New
	printer for std::regex NFA states.
2022-01-05 13:47:02 +00:00
Jonathan Wakely 749ee73406 libstdc++: Fix comments in std::forward_list tests
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/forward_list/operations/1.cc: Fill in
	placeholders in comments.
	* testsuite/23_containers/forward_list/operations/2.cc:
	Likewise.
	* testsuite/23_containers/forward_list/operations/3.cc:
	Likewise.
	* testsuite/23_containers/forward_list/operations/4.cc:
	Likewise.
	* testsuite/23_containers/forward_list/operations/5.cc:
	Likewise.
	* testsuite/23_containers/forward_list/operations/6.cc:
	Likewise.
	* testsuite/23_containers/forward_list/operations/7.cc:
	Likewise.
2022-01-05 13:47:02 +00:00
Jonathan Wakely 76a45931ab libstdc++: Avoid -Wzero-as-null-pointer-constant warning [PR103848]
libstdc++-v3/ChangeLog:

	PR libstdc++/103848
	* include/bits/stl_deque.h (operator-): Do not use 0 as null
	pointer constant.
2022-01-05 13:47:02 +00:00
Jonathan Wakely 917c7b136e libstdc++: Simplify std::allocator_traits<allocator<void>>::construct
We don't need a preprocessor condition to decide whether to use
placement new or std::construct_at, because std::_Construct already does
that.

libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h (allocator_traits<allocator<void>>):
	Use std::_Construct for construct.
2022-01-05 13:47:01 +00:00
Jonathan Wakely cebe875f6f libstdc++: Fix example preprocessor command in FAQ [PR103877]
libstdc++-v3/ChangeLog:

	PR libstdc++/103877
	* doc/xml/faq.xml: Add '-x c++' to preprocessor command.
	* doc/html/faq.html: Regenerate.
2022-01-05 13:47:01 +00:00
Jonathan Wakely e09366718a libstdc++: Reduce template instantiations in <regex>
This moves the last two template parameters of __regex_algo_impl to be
runtime function parameters instead, so that we don't need four
different instantiations for the possible ways to call it. Most of the
function (and what it instantiates) is the same in all cases, so making
them compile-time choices doesn't really have much benefit.

Use  'if constexpr' for conditions that check template parameters, so
that when we do depend on a compile-time condition we only instantiate
what we need to.

libstdc++-v3/ChangeLog:

	* include/bits/regex.h (__regex_algo_impl): Change __policy and
	__match_mode template parameters to be function parameters.
	(regex_match, regex_search): Pass policy and match mode as
	function arguments.
	* include/bits/regex.tcc (__regex_algo_impl): Change template
	parameters to function parameters.
	* include/bits/regex_compiler.h (_RegexTranslatorBase): Use
	'if constexpr' for conditions using template parameters.
	(_RegexTranslator): Likewise.
	* include/bits/regex_executor.tcc (_Executor::_M_handle_accept):
	Likewise.
	* testsuite/util/testsuite_regex.h (regex_match_debug)
	(regex_search_debug): Move template arguments to function
	arguments.
2022-01-05 13:47:01 +00:00
Jonathan Wakely 9a2451c101 libstdc++: Compare match_results for failed regex_match
The regex_match_debug testsuite helper doesn't compare the
std::match_results objects after a failed match, but it should do. The
standard says that the effects of a failed match on the match-results
are unspecified, except that [conditions testable by operator==]. So we
can check that the two sets of results compare equal even if the match
failed.

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_regex.h (regex_match_debug): Compare
	results even if the match failed.
2022-01-05 13:47:00 +00:00
Jonathan Wakely 260a5334ee libstdc++: Improve std::regex_error::what() strings
This replaces the vague "regex_error" for std::regex_error::what() with
a string that corresponds to the error_type enum passed to the
constructor. This allows us to remove many of the strings passed to
__throw_regex_error, because the default string is at least as good.
When a string argument to __throw_regex_error is kept it should add some
context-specific detail absent from the default string.

Also remove full stops (periods) from the end of those strings, to make
it easier to include them in logs and other output. I've left them
starting with an upper-case letter, which is consistent with strerror
output for (at least) Glibc, Solaris and BSD. I'm ambivalent whether
that's the right choice.

This also adds the missing noreturn attribute to __throw_regex_error.

libstdc++-v3/ChangeLog:

	* include/bits/regex_compiler.tcc: Adjust all calls to
	__throw_regex_error.
	* include/bits/regex_error.h (__throw_regex_error): Add noreturn
	attribute.
	* include/bits/regex_scanner.tcc: Likewise.
	* src/c++11/regex.cc (desc): New helper function.
	(regex_error::regex_error(error_type)): Use desc to get a string
	corresponding to the error code.
2022-01-05 13:47:00 +00:00
Jakub Jelinek 7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Jakub Jelinek 6123f29a18 Rotate ChangeLog files - step 2 - remove 2021 entries from ChangeLog files.
Can't be committed together with the previous one due to the ChangeLog vs.
other files restrictions.
2022-01-03 10:23:34 +01:00
Jakub Jelinek d04ae83244 Rotate ChangeLog files - part 1 - add ChangeLog-2021.
2022-01-03  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* ChangeLog-2021: Rotate ChangeLog.  New file.
gcc/ada/
	* ChangeLog-2021: Rotate ChangeLog.  New file.
gcc/cp/
	* ChangeLog-2021: Rotate ChangeLog.  New file.
gcc/d/
	* ChangeLog-2021: Rotate ChangeLog.  New file.
gcc/fortran/
	* ChangeLog-2021: Rotate ChangeLog.  New file.
gcc/testsuite/
	* ChangeLog-2021: Rotate ChangeLog.  New file.
libgfortran/
	* ChangeLog-2021: Rotate ChangeLog.  New file.
libstdc++-v3/
	* ChangeLog-2021: Rotate ChangeLog.  New file.
2022-01-03 10:18:16 +01:00
GCC Administrator 8a89c39be0 Daily bump. 2021-12-16 00:16:28 +00:00
François Dumont 807ad4bc85 libstdc++: Overload std::__to_address for __gnu_cxx::__normal_iterator.
Prefer to overload __to_address to partially specialize std::pointer_traits because
std::pointer_traits would be mostly useless. Moreover partial specialization of
pointer_traits<__normal_iterator<P, C>> fails to rebind C, so you get incorrect types
like __normal_iterator<long*, vector<int>>. In the case of __gnu_debug::_Safe_iterator
the to_pointer method is impossible to implement correctly because we are missing
the parent container to associate the iterator to.

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h
	(std::pointer_traits<__gnu_cxx::__normal_iterator<>>): Remove.
	(std::__to_address(const __gnu_cxx::__normal_iterator<>&)): New for C++11 to C++17.
	* include/debug/safe_iterator.h
	(std::__to_address(const __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<>,
	_Sequence>&)): New for C++11 to C++17.
	* testsuite/24_iterators/normal_iterator/to_address.cc: Add check on std::vector::iterator
	to validate both __gnu_cxx::__normal_iterator<> __to_address overload in normal mode and
	__gnu_debug::_Safe_iterator in _GLIBCXX_DEBUG mode.
2021-12-15 22:28:05 +01:00
Jakub Jelinek a5b4ebc217 libstdc++: Poor man's case insensitive comparisons in time_get [PR71557]
This patch uses the same not completely correct case insensitive comparisons
as used elsewhere in the same header.  Proper comparisons that would handle
even multi-byte characters would be harder, but I don't see them implemented
in __ctype's methods.

2021-12-15  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/71557
	* include/bits/locale_facets_nonio.tcc (_M_extract_via_format):
	Compare characters other than format specifiers and whitespace
	case insensitively.
	(_M_extract_name): Compare characters case insensitively.
	* testsuite/22_locale/time_get/get/char/71557.cc: New test.
	* testsuite/22_locale/time_get/get/wchar_t/71557.cc: New test.
2021-12-15 10:25:53 +01:00
GCC Administrator 9c6586bc20 Daily bump. 2021-12-15 00:16:28 +00:00
Jonathan Wakely 9a4b4514bd libstdc++: Support old and new T_FMT for en_HK locale [PR103687]
This checks whether the locale data for en_HK includes %p and adjusts
the string being tested accordingly. To account for Jakub's fix to make
%I parse "12" as 0 instead of 12, we need to change the expected value
for the case where the locale format doesn't include %p. Also change the
time from 12:00:00 to 12:02:01 so we can tell if the minutes and seconds
get mixed up.

libstdc++-v3/ChangeLog:

	PR libstdc++/103687
	* testsuite/22_locale/time_get/get_date/wchar_t/4.cc: Restore
	original locale before returning.
	* testsuite/22_locale/time_get/get_time/char/2.cc: Check for %p
	in locale's T_FMT and adjust accordingly.
	* testsuite/22_locale/time_get/get_time/wchar_t/2.cc: Likewise.
2021-12-14 23:37:14 +00:00
Jonathan Wakely 7ce3c230ed libstdc++: Fix handling of invalid ranges in std::regex [PR102447]
std::regex currently allows invalid bracket ranges such as [\w-a] which
are only allowed by ECMAScript when in web browser compatibility mode.
It should be an error, because the start of the range is a character
class, not a single character. The current implementation of
_Compiler::_M_expression_term does not provide a way to reject this,
because we only remember a previous character, not whether we just
processed a character class (or collating symbol etc.)

This patch replaces the pair<bool, CharT> used to emulate
optional<CharT> with a custom class closer to pair<tribool,CharT>. That
allows us to track three states, so that we can tell when we've just
seen a character class.

With this additional state the code in _M_expression_term for processing
the _S_token_bracket_dash can be improved to correctly reject the [\w-a]
case, without regressing for valid cases such as [\w-] and [----].

libstdc++-v3/ChangeLog:

	PR libstdc++/102447
	* include/bits/regex_compiler.h (_Compiler::_BracketState): New
	class.
	(_Compiler::_BrackeyMatcher): New alias template.
	(_Compiler::_M_expression_term): Change pair<bool, CharT>
	parameter to _BracketState. Process first character for
	ECMAScript syntax as well as POSIX.
	* include/bits/regex_compiler.tcc
	(_Compiler::_M_insert_bracket_matcher): Pass _BracketState.
	(_Compiler::_M_expression_term): Use _BracketState to store
	state between calls. Improve handling of dashes in ranges.
	* testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc:
	Add more tests for ranges containing dashes. Check invalid
	ranges with character class at the beginning.
2021-12-14 21:45:46 +00:00
Jonathan Wakely fda2872270 libstdc++: Simplify typedefs by using __UINTPTR_TYPE__
libstdc++-v3/ChangeLog:

	* include/ext/pointer.h (_Relative_pointer_impl::_UIntPtrType):
	Rename to uintptr_t and define as __UINTPTR_TYPE__.
2021-12-14 21:45:46 +00:00
Jonathan Wakely 63bb98e1c1 libstdc++: Simplify definition of std::regex_constants variables
This removes the __syntax_option and __match_flag enumeration types,
which are only used to define enumerators with successive values that
are then used to initialize the std::regex_constants global variables.

By defining enumerators in the syntax_option_type and match_flag_type
enumeration types with the correct values for the globals we get rid of
two useless enumeration types that just count from 0 to N, and we
improve the debugging experience. Because the enumeration types now have
enumerators defined, GDB will print values in terms of those enumerators
e.g.

$6 = (std::regex_constants::_S_ECMAScript | std::regex_constants::_S_multiline)

Previously this would have been shown as simply 0x810 because there were
no enumerators of that type.

This changes the type and value of enumerators such as _S_grep, but
users should never be referring to them directly anyway.

libstdc++-v3/ChangeLog:

	* include/bits/regex_constants.h (__syntax_option, __match_flag):
	Remove.
	(syntax_option_type, match_flag_type): Define enumerators.
	Use to initialize globals. Add constexpr to compound assignment
	operators.
	* include/bits/regex_error.h (error_type): Add comment.
	* testsuite/28_regex/constants/constexpr.cc: Remove comment.
	* testsuite/28_regex/constants/error_type.cc: Improve comment.
	* testsuite/28_regex/constants/match_flag_type.cc: Check bitmask
	requirements.
	* testsuite/28_regex/constants/syntax_option_type.cc: Likewise.
2021-12-14 21:45:45 +00:00
Jonathan Wakely b0e6a257f1 libstdc++: Fix non-reserved name in <regex> header
libstdc++-v3/ChangeLog:

	* include/bits/regex_compiler.tcc (_Compiler::_M_match_token):
	Use reserved name for parameter.
	* testsuite/17_intro/names.cc: Check "token".
2021-12-14 14:23:55 +00:00