Commit Graph

8046 Commits

Author SHA1 Message Date
Matthias Kretz 1a62008123 libstdc++: Fix operator% implementation for Clang
This resolves a regression of my previous fix where Clang would ICE on
_S_divides.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_x86.h (_SimdImplX86): Use
	_Base::_S_divides if the optimized _S_divides function is hidden
	via the preprocessor.
2023-03-28 12:41:35 +02:00
Jonathan Wakely a495b738e4 libstdc++: Fix assigning nullptr to std::atomic<shared_ptr<T>> (LWG 3893)
LWG voted this to Tentatively Ready recently.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (atomic::operator=(nullptr_t)):
	Add overload, as per LWG 3893.
	* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc:
	Check assignment from nullptr.
2023-03-22 23:13:40 +00:00
Jonathan Wakely f2e70da638 libstdc++: Remove std::formatter<const charT[N], charT> specialization
This was approved in Issaquah as LWG 3833.

libstdc++-v3/ChangeLog:

	* include/std/format (formatter<const charT[N], charT>): Do not
	define partial speclialization, as per LWG 3833.
	* testsuite/std/format/formatter/requirements.cc: Check it.
2023-03-22 17:48:20 +00:00
Jonathan Wakely 924d990425 libstdc++: Define __cpp_lib_constexpr_algorithms in <utility> (LWG 3792)
We actually defined this macro in <utility> at one point, but I removed
it in r10-7901-g2025db692e9ed1.

libstdc++-v3/ChangeLog:

	* include/std/utility (__cpp_lib_constexpr_algorithms): Define,
	as per LWG 3792.
	* testsuite/20_util/exchange/constexpr.cc: Check for it.
2023-03-22 17:48:20 +00:00
Jonathan Wakely 02e86035d3 libstdc++: Add missing __cpp_lib_format macro to <version>
libstdc++-v3/ChangeLog:

	* include/std/version (__cpp_lib_format): Define.
	* testsuite/std/format/functions/format.cc: Check it.
2023-03-22 17:48:20 +00:00
Jonathan Wakely ba4f5530c4 libstdc++: Use rvalues in std::string::resize_and_overwrite (LWG 3645)
Previously the C++23 draft required that the callback arguments were
lvalues, which was overvable by the callback. LWG 3645 removes that
overspecification, so we can pass rvalues and the user can't modify
our local variables. I've used auto(p) to produce rvalues, which is only
supported since Clang 15, but I think that's OK for a C++23 feature.

While making this change I noticed that we weren't correctly enforcing
the requirement that the callback returns an integer-like type. Add
better assertions for the type and value.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.tcc (basic_string::resize_and_overwrite):
	Pass rvalues to the callback, as now allowed by LWG 3645.
	Enforce preconditions on the return value.
	* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
	Adjust.
2023-03-22 17:48:20 +00:00
Jonathan Wakely 7d4f4ce6a5 libstdc++: Add comment to <format> (LWG 3720)
libstdc++-v3/ChangeLog:

	* include/std/format: Add a comment noting that the resolution
	of LWG 3720 has been applied..
2023-03-22 17:48:19 +00:00
Jonathan Wakely 9ae1108196 libstdc++: Add allocator-extended constructors to std::match_results (LWG 2195)
This was approved in Issaquah last month.

libstdc++-v3/ChangeLog:

	* include/bits/regex.h (match_results): Add allocator-extended
	copy and move constructors, as per LWG 2195.
	* testsuite/28_regex/match_results/ctors/char/alloc.cc: New test.
2023-03-22 17:48:19 +00:00
Jonathan Wakely ad0b9cf1a0 libstdc++: Make std::istream_iterator copy ctor constexpr (LWG 3600)
As explained in LWG 3600, we never implemented a C++0x change that made
the copy constructor of std::istream_iterator defined as defaulted. That
would be an ABI break, so the resolution of LWG 3600 is to not require
it to be trivial, but just constexpr and conditionally noexcept. This
applies that resolution.

libstdc++-v3/ChangeLog:

	* include/bits/stream_iterator.h (istream_iterator): Add
	constexpr to copy constructor, as per LWG 3600.
	* testsuite/24_iterators/istream_iterator/cons/constexpr.cc:
	Check copy construction.
2023-03-22 17:48:19 +00:00
Matthias Kretz fac64bf456 libstdc++: Use more precise __RECIPROCAL_MATH__ macro
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_x86.h
	(_SimdImplX86::_S_divides): Replace test for __GCC_IEC_559 == 0
	with __RECIPROCAL_MATH__.
2023-03-21 20:30:19 +01:00
Matthias Kretz 403e48ef44 libstdc++: Skip integer division optimization for Clang
Clang ICEs on _SimdImplX86::_S_divides. The function is only working
around a missed optimization and not necessary for correctness.
Therefore, don't use it for Clang.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_detail.h: Don't define
	_GLIBCXX_SIMD_WORKAROUND_PR90993 for Clang.
	* include/experimental/bits/simd_x86.h (_S_divides): Remove
	check for __clang__.
2023-03-21 20:30:19 +01:00
Matthias Kretz 8ff3ca2d94 libstdc++: Fix simd compilation with Clang
Clang fails to compile some constant expressions involving simd.
Therefore, just disable this non-conforming extension for clang.

Fix AVX512 blend implementation for Clang. It was converting the bitmask
to bool before, which is obviously wrong. Instead use a Clang builtin to
convert the bitmask to vector-mask before using a vector blend ?:. A
similar change is required for the masked unary implementation, because
the GCC builtins do not exist on Clang.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_detail.h: Don't declare the
	simd API as constexpr with Clang.
	* include/experimental/bits/simd_x86.h (__movm): New.
	(_S_blend_avx512): Resolve FIXME. Implement blend using __movm
	and ?:.
	(_SimdImplX86::_S_masked_unary): Clang does not implement the
	same builtins. Implement the function using __movm, ?:, and -
	operators on vector_size types instead.
2023-03-21 17:47:25 +01:00
Jonathan Wakely 5194ad1958 libstdc++: Remove template-head from std::expected<void> ctor [PR109182]
The presence of a template-head on this constructor is a copy & paste
error from the primary template.

libstdc++-v3/ChangeLog:

	PR libstdc++/109182
	* include/std/expected (expected<void>::expected(in_place_t)):
	Remove template-head.
2023-03-20 09:33:23 +00:00
Jonathan Wakely c48be8298c libstdc++: Add const to hash<coroutine_handle<P>>::operator() [PR109165]
libstdc++-v3/ChangeLog:

	PR libstdc++/109165
	* include/std/coroutine (hash<>::operator()): Add const.
	* testsuite/18_support/coroutines/hash.cc: New test.
2023-03-17 20:34:52 +00:00
Patrick Palka 578f633dda libstdc++: Fix template-head of repeat_view::_Iterator [PR109111]
PR libstdc++/109111

libstdc++-v3/ChangeLog:

	* include/std/ranges (repeat_view): Remove redundant parentheses
	in requires-clause.
	(repeat_view::_Iterator): Correct the requires-clause.
2023-03-14 19:06:33 -04:00
Patrick Palka 2b204accd0 libstdc++: Implement P2520R0 changes to move_iterator's iterator_concept
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (move_iterator::_S_iter_concept):
	Define.
	(__cpp_lib_move_iterator_concept): Define for C++20.
	(move_iterator::iterator_concept): Strengthen as per P2520R0.
	* include/std/version (__cpp_lib_move_iterator_concept): Define
	for C++20.
	* testsuite/24_iterators/move_iterator/p2520r0.cc: New test.
2023-03-14 16:44:32 -04:00
Patrick Palka f2e7dd8b02 libstdc++: Implement LWG 3715 changes to view_interface::empty
libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (view_interface::empty): Add
	preferred overloads that use ranges::size when the range is
	sized as per LWG 3715.
	* testsuite/std/ranges/adaptors/lwg3715.cc: New test.
2023-03-14 16:44:30 -04:00
Jonathan Wakely 4d771291f7 libstdc++: Fix preprocessor condition for inline variables
Although variable templates are valid in C++14, inline ones aren't.
These are only used in C++17 (or later) code, so they don't need to be
defined for C++14.

libstdc++-v3/ChangeLog:

	* include/bits/chrono.h (__is_duration_v, __is_time_point_v):
	Only define for C++17 and later.
2023-03-14 10:28:38 +00:00
Jonathan Wakely abb958ada1 libstdc++: Add assertions to std::mask_array operations [PR62196]
Add assertions to diagnose incorrect uses of valarray masks.

The assignment operators of std::mask_array do not have any explicit
preconditions in the standard, but the assignment operator
valarray<T>::operator=(const mask_array<T>&) requires the lengths to
match, so it seems consistent to also require that when the operands are
reversed.  In support of that interpretation, libstdc++ has undefined
behaviour if the right-hand operand has more elements than are selected
by the mask, and libc++ has undefined behaviour if it has fewer
elements. Our std::mask_array stores the number of selected elements as
_M_sz so it's easy to add an assertion that checks it.

For the valarray::operator[] that takes a valarray<bool> mask,
[valarray.sub] in the standard says: "In each case the selected
element(s) shall exist." This makes it undefined to have a mask that
refers to out-of-range elements. We can easily check this too.

libstdc++-v3/ChangeLog:

	PR libstdc++/62196
	* include/bits/mask_array.h (mask_array): Add assertions to
	assignment operators.
	* include/std/valarray (valarray::operator[](valarray<bool>)):
	Add assertions.
	* testsuite/26_numerics/valarray/mask-1_neg.cc: New test.
	* testsuite/26_numerics/valarray/mask-2_neg.cc: New test.
	* testsuite/26_numerics/valarray/mask-3_neg.cc: New test.
	* testsuite/26_numerics/valarray/mask-4_neg.cc: New test.
	* testsuite/26_numerics/valarray/mask-5_neg.cc: New test.
	* testsuite/26_numerics/valarray/mask-6_neg.cc: New test.
	* testsuite/26_numerics/valarray/mask-7_neg.cc: New test.
	* testsuite/26_numerics/valarray/mask-8_neg.cc: New test.
	* testsuite/26_numerics/valarray/mask.cc: New test.
2023-03-14 10:28:38 +00:00
Jonathan Wakely a1d4d92d6a libstdc++: Fix typo in comment
Reported by Jonny Grant.

libstdc++-v3/ChangeLog:

	* include/bits/allocator.h: Fix typo in comment.
2023-03-13 10:32:26 +00:00
Patrick Palka 96abc82224 libstdc++: Implement LWG 3820/3849 changes to cartesian_product_view
The LWG 3820 testcase revealed a bug in _M_advance, which this patch
also fixes.

libstdc++-v3/ChangeLog:

	* include/std/ranges
	(cartesian_product_view::_Iterator::_Iterator): Remove
	constraint on default constructor as per LWG 3849.
	(cartesian_product_view::_Iterator::_M_prev): Adjust position
	of _Nm > 0 test as per LWG 3820.
	(cartesian_product_view::_Iterator::_M_advance): Perform bounds
	checking only on sized cartesian products.
	* testsuite/std/ranges/cartesian_product/1.cc (test08): New test.
2023-03-09 13:41:03 -05:00
Patrick Palka 065c93b89c libstdc++: Implement LWG 3796 changes to repeat_/chunk_by_view [PR109024]
PR libstdc++/109024

libstdc++-v3/ChangeLog:

	* include/std/ranges (chunk_by_view::_M_pred): Remove DMI as per
	LWG 3796.
	(repeat_view::_M_pred): Likewise.
	* testsuite/std/ranges/adaptors/chunk_by/1.cc (test03): New test.
	* testsuite/std/ranges/repeat/1.cc (test05): New test.
2023-03-09 13:37:29 -05:00
Patrick Palka 95827e1b9f libstdc++: Make views::single/iota/istream SFINAE-friendly [PR108362]
PR libstdc++/108362

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__can_single_view): New concept.
	(_Single::operator()): Constrain it.  Move [[nodiscard]] to the
	end of the function declarator.
	(__detail::__can_iota_view): New concept.
	(_Iota::operator()): Constrain it.  Move [[nodiscard]] to the
	end of the function declarator.
	(__detail::__can_istream_view): New concept.
	(_Istream::operator()): Constrain it.  Move [[nodiscard]] to the
	end of the function declarator.
	* testsuite/std/ranges/iota/iota_view.cc (test07): New test.
	* testsuite/std/ranges/istream_view.cc (test08): New test.
	* testsuite/std/ranges/single_view.cc (test07): New test.
2023-03-09 13:35:04 -05:00
Patrick Palka 3df9760d56 libstdc++: extraneous begin in cartesian_product_view::end [PR107572]
ranges::begin() isn't guaranteed to be equality-preserving for non-forward
ranges, so in cartesian_product_view::end we need to avoid needlessly
calling begin() on the first range (which could be non-forward) in the
case where __empty_tail is false as per its specification.

Since we're already using a variadic lambda to compute __empty_tail, we
might as well use that same lambda to build up the tuple of iterators
instead of building it separately via e.g. std::apply or __tuple_transform.

	PR libstdc++/107572

libstdc++-v3/ChangeLog:

	* include/std/ranges (cartesian_product_view::end): When
	building the tuple of iterators, avoid calling ranges::begin on
	the first range if __empty_tail is false.
	* testsuite/std/ranges/cartesian_product/1.cc (test07): New test.
2023-03-09 13:25:44 -05:00
Alexandre Oliva 21edd84161 link pthread_join from std::thread ctor
Like pthread_create, pthread_join may fail to be statically linked in
absent strong uses, so add to user code strong references to both when
std::thread objects are created.


for  libstdc++-v3/ChangeLog

	PR libstdc++/104852
	PR libstdc++/95989
	PR libstdc++/52590
	* include/bits/std_thread.h (thread::_M_thread_deps): New
	static implicitly-inline member function.
	(std::thread template ctor): Pass it to _M_start_thread.
	* src/c++11/thread.cc (thread::_M_start_thread): Name depend
	parameter, force it live on entry.
2023-03-03 16:06:44 -03:00
Jonathan Wakely c54cae823f libstdc++: Fix typo in comment in bits/cow_string.h
libstdc++-v3/ChangeLog:

	* include/bits/cow_string.h: Fix typo in comment.
2023-03-01 21:26:08 +00:00
Jonathan Wakely 8e342c0455 libstdc++: Fix uses_allocator_construction_args for pair<T&&, U&&> [PR108952]
This implements LWG 3527 which fixes the handling of pair<T&&, U&&> in
std::uses_allocator_construction_args.

libstdc++-v3/ChangeLog:

	PR libstdc++/108952
	* include/bits/uses_allocator_args.h
	(uses_allocator_construction_args): Implement LWG 3527.
	* testsuite/20_util/pair/astuple/get-2.cc: New test.
	* testsuite/20_util/scoped_allocator/108952.cc: New test.
	* testsuite/20_util/uses_allocator/lwg3527.cc: New test.
2023-02-28 09:49:11 +00:00
Jonathan Wakely 822a11a1e6 libstdc++: Do not use memmove for 1-element ranges [PR108846]
This avoids overwriting tail padding when algorithms like std::copy are
used to write a single value through a pointer to a base subobject.

The pointer arithmetic on a Base* is valid for N==1, but the copy/move
operation needs to be done using assignment, not a memmove or memcpy of
sizeof(Base) bytes.

Instead of putting a check for N==1 in all of copy, copy_n, move etc.
this adds it to the __copy_move and __copy_move_backward partial
specializations used for trivially copyable types. When N==1 those
partial specializations dispatch to new static member functions of the
partial specializations for non-trivial types, so that a copy/move
assignment is done appropriately for the _IsMove constant.

libstdc++-v3/ChangeLog:

	PR libstdc++/108846
	* include/bits/stl_algobase.h (__copy_move<false, false, RA>)
	Add __assign_one static member function.
	(__copy_move<true, false, RA>): Likewise.
	(__copy_move<IsMove, true, RA>): Do not use memmove for a single
	value.
	(__copy_move_backward<IsMove, true, RA>): Likewise.
	* testsuite/25_algorithms/copy/108846.cc: New test.
	* testsuite/25_algorithms/copy_backward/108846.cc: New test.
	* testsuite/25_algorithms/copy_n/108846.cc: New test.
	* testsuite/25_algorithms/move/108846.cc: New test.
	* testsuite/25_algorithms/move_backward/108846.cc: New test.
2023-02-28 09:49:11 +00:00
Jonathan Wakely dfa85beebf libstdc++: Add Doxygen comment for string::resize_and_overwite
This is a complicated API that should be clearly documented.

Also improve the comment on basic_ios::_M_setstate.

libstdc++-v3/ChangeLog:

	* include/bits/basic_ios.h (basic_ios::_M_setstate): Add
	caveat to comment.
	* include/bits/basic_string.h (resize_and_overwrite): Add
	doxygen comment.
2023-02-27 13:42:21 +00:00
Matthias Kretz b31186e589 libstdc++: Fix formatting
Whitespace changes only.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h: Line breaks and indenting
	fixed to follow the libstdc++ standard.
	* include/experimental/bits/simd_builtin.h: Likewise.
	* include/experimental/bits/simd_fixed_size.h: Likewise.
	* include/experimental/bits/simd_neon.h: Likewise.
	* include/experimental/bits/simd_ppc.h: Likewise.
	* include/experimental/bits/simd_scalar.h: Likewise.
	* include/experimental/bits/simd_x86.h: Likewise.
2023-02-24 19:38:57 +01:00
Matthias Kretz e37b04328a libstdc++: Always-inline most of non-cmath fixed_size implementation
For simd, the inlining behavior should be similar to builtin types. (No
operator on buitin types is ever translated into a function call.)
Therefore, always_inline is the right choice (i.e. inline on -O0 as
well).

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

libstdc++-v3/ChangeLog:

	PR libstdc++/108030
	* include/experimental/bits/simd_fixed_size.h
	(_SimdImplFixedSize::_S_broadcast): Replace inline with
	_GLIBCXX_SIMD_INTRINSIC.
	(_SimdImplFixedSize::_S_generate): Likewise.
	(_SimdImplFixedSize::_S_load): Likewise.
	(_SimdImplFixedSize::_S_masked_load): Likewise.
	(_SimdImplFixedSize::_S_store): Likewise.
	(_SimdImplFixedSize::_S_masked_store): Likewise.
	(_SimdImplFixedSize::_S_min): Likewise.
	(_SimdImplFixedSize::_S_max): Likewise.
	(_SimdImplFixedSize::_S_complement): Likewise.
	(_SimdImplFixedSize::_S_unary_minus): Likewise.
	(_SimdImplFixedSize::_S_plus): Likewise.
	(_SimdImplFixedSize::_S_minus): Likewise.
	(_SimdImplFixedSize::_S_multiplies): Likewise.
	(_SimdImplFixedSize::_S_divides): Likewise.
	(_SimdImplFixedSize::_S_modulus): Likewise.
	(_SimdImplFixedSize::_S_bit_and): Likewise.
	(_SimdImplFixedSize::_S_bit_or): Likewise.
	(_SimdImplFixedSize::_S_bit_xor): Likewise.
	(_SimdImplFixedSize::_S_bit_shift_left): Likewise.
	(_SimdImplFixedSize::_S_bit_shift_right): Likewise.
	(_SimdImplFixedSize::_S_remquo): Add inline keyword (to be
	explicit about not always-inline, yet).
	(_SimdImplFixedSize::_S_isinf): Likewise.
	(_SimdImplFixedSize::_S_isfinite): Likewise.
	(_SimdImplFixedSize::_S_isnan): Likewise.
	(_SimdImplFixedSize::_S_isnormal): Likewise.
	(_SimdImplFixedSize::_S_signbit): Likewise.
2023-02-24 19:34:28 +01:00
Matthias Kretz 6ce55180d4 libstdc++: More efficient masked inc-/decrement implementation
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	PR libstdc++/108856
	* include/experimental/bits/simd_builtin.h
	(_SimdImplBuiltin::_S_masked_unary): More efficient
	implementation of masked inc-/decrement for integers and floats
	without AVX2.
	* include/experimental/bits/simd_x86.h
	(_SimdImplX86::_S_masked_unary): New. Use AVX512 masked subtract
	builtins for masked inc-/decrement.
2023-02-24 19:34:28 +01:00
Jonathan Wakely 8520132bc3 libstdc++: Constrain net::executor constructors
The TS says the arguments to these constructors shall meet the Executor
requirements, so it's undefined if they don't. Constraining on a subset
of those requirements won't affect valid cases, but prevents the
majority of invalid cases from trying to instantiate the constructor.

This prevents the non-explicit executor(Executor) constructor being a
candidate anywhere that a net::executor could be constructed e.g.
comparing ip::tcp::v4() == ip::udp::v4() would try to convert both
operands to executor using that constructor, then compare then using
operator==(const executor&, const executor&).

libstdc++-v3/ChangeLog:

	* include/experimental/executor (executor): Constrain template
	constructors.
2023-02-24 14:23:36 +00:00
Jonathan Wakely 97111dccf9 libstdc++: Make net::ip::basic_endpoint comparisons constexpr
libstdc++-v3/ChangeLog:

	* include/experimental/internet (basic_endpoint): Add missing
	constexpr to comparison operators.
	* testsuite/experimental/net/internet/endpoint/cons.cc: New test.
2023-02-24 14:23:36 +00:00
Jonathan Wakely 80e9bac232 libstdc++: Fix members of net::ip::network_v4
libstdc++-v3/ChangeLog:

	* include/experimental/internet (network_v4::netmask()): Avoid
	undefined shift.
	(network_v4::broadcast()): Optimize and fix for targets with
	uint_least32_t wider than 32 bits.
	(network_v4::to_string(const Allocator&)): Fix for custom
	allocators and optimize using to_chars.
	(operator==(const network_v4&, const network_v4&)): Add missing
	constexpr.
	(operator==(const network_v6&, const network_v6&)): Likewise.
	* testsuite/experimental/net/internet/network/v4/cons.cc: New test.
	* testsuite/experimental/net/internet/network/v4/members.cc: New test.
2023-02-24 14:23:36 +00:00
Jonathan Wakely 36ecfb75e0 libstdc++: Fix conversion to/from net::ip::address_v4::bytes_type
I messed up the endianness of the address_v4::bytes_type array, which
should always be in network byte order. We can just use bit_cast to
convert the _M_addr member to/from bytes_type.

libstdc++-v3/ChangeLog:

	* include/experimental/internet (address_4(const bytes_type&)):
	Use __builtin_bit_cast if available, otherwise convert to
	network byte order.
	(address_v4::to_bytes()): Likewise, but convert from network
	byte order.
	* testsuite/experimental/net/internet/address/v4/cons.cc: Fix
	incorrect tests. Check for constexpr too.
	* testsuite/experimental/net/internet/address/v4/creation.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v4/members.cc:
	Check that bytes_type is a standard-layout type.
2023-02-24 14:23:36 +00:00
Jonathan Wakely 363f0ef50b libstdc++: Optimize net::ip::address_v4::to_string()
This is an order of magnitude faster than calling inet_ntop (and not
only because we now avoid allocating a string that is one byte larger
than the SSO buffer).

libstdc++-v3/ChangeLog:

	* include/experimental/internet (address_v4::to_string):
	Optimize.
	* testsuite/experimental/net/internet/address/v4/members.cc:
	Check more addresses.
2023-02-24 14:23:35 +00:00
Jonathan Wakely ae39047934 libstdc++: Suppress warnings about use of deprecated std::aligned_storage
libstdc++-v3/ChangeLog:

	* include/ext/aligned_buffer.h (__aligned_buffer): Add
	diagnostic pragmas.
2023-02-24 14:23:35 +00:00
Matthias Kretz ffa39f7120 libstdc++: Fix -Wsign-compare issue
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_builtin.h (_S_set): Compare as
	int. The actual range of these indexes is very small.
2023-02-23 15:01:49 +01:00
Matthias Kretz fa37ac2b59 libstdc++: Add missing constexpr on simd shift implementation
Resolves -Wtautological-compare warnings about `if
(__builtin_is_constant_evaluated())` in the implementations of these
functions.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_x86.h (_S_bit_shift_left)
	(_S_bit_shift_right): Declare constexpr. The implementation was
	already expecting constexpr evaluation.
2023-02-23 15:01:49 +01:00
Matthias Kretz 92c47b15d5 libstdc++: Fix simd build failure on clang
Clang does not support __attribute__ on lambdas. Therefore, only set
_GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA if __clang__ is not defined.

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

libstdc++-v3/ChangeLog:

	PR libstdc++/108030
	* include/experimental/bits/simd_detail.h
	(_GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA): Define as empty for
	__clang__.
2023-02-23 15:01:49 +01:00
Matthias Kretz 2e29e2fbeb libstdc++: Simplify three helper functions into one
Broadcast is a very common function. This should reduce compile-time
effort.

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

libstdc++-v3/ChangeLog:

	PR libstdc++/108030
	* include/experimental/bits/simd.h (__vector_broadcast):
	Implement via __vector_broadcast_impl instead of
	__call_with_n_evaluations + 2 lambdas.
	(__vector_broadcast_impl): New.
2023-02-23 15:01:49 +01:00
Matthias Kretz bb920f561e libstdc++: Fix uses of non-reserved names in simd header
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h (__extract_part, split):
	Use reserved name for template parameter.
2023-02-20 17:24:03 +01:00
Matthias Kretz a5de17d912 libstdc++: Fix incorrect function call in -ffast-math optimization
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_math.h (__hypot): Bitcasting
	between scalars requires the __bit_cast helper function instead
	of simd_bit_cast.
2023-02-16 15:58:34 +01:00
Matthias Kretz 1fd3836463 libstdc++: Fix incorrect __builtin_is_constant_evaluated calls
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_x86.h
	(_SimdImplX86::_S_not_equal_to, _SimdImplX86::_S_less)
	(_SimdImplX86::_S_less_equal): Do not call
	__builtin_is_constant_evaluated in constexpr-if.
2023-02-16 15:58:33 +01:00
Matthias Kretz 53b55701ae libstdc++: Annotate most lambdas with always_inline
All of the annotated lambdas are simply a necessary means for
implementing these functions and should never result in an actual
function call. Many of these lambdas would go away if C++ had better
language support for packs.

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

libstdc++-v3/ChangeLog:

	PR libstdc++/108030
	* include/experimental/bits/simd_detail.h: Define
	_GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA.
	* include/experimental/bits/simd.h: Annotate lambdas with
	_GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA.
	* include/experimental/bits/simd_builtin.h: Ditto.
	* include/experimental/bits/simd_converter.h: Ditto.
	* include/experimental/bits/simd_fixed_size.h: Ditto.
	* include/experimental/bits/simd_math.h: Ditto.
	* include/experimental/bits/simd_neon.h: Ditto.
	* include/experimental/bits/simd_x86.h: Ditto.
2023-02-16 15:58:33 +01:00
Matthias Kretz fea34ee491 libstdc++: Ensure __builtin_constant_p isn't lost on the way
The more expensive code path should only be taken if it can be optimized
away.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h
	(_SimdWrapper::_M_is_constprop_none_of)
	(_SimdWrapper::_M_is_constprop_all_of): Return false unless the
	computed result still satisfies __builtin_constant_p.
2023-02-16 15:58:33 +01:00
Jonathan Wakely b85c77e19a libstdc++: Implement <experimental/synchronized_value> (P0290)
This was approved for the Concurrency TS v2 in Issaquah.

Although the TS is based on C++20, this enables the new header for C++17
as well. This will make it available to more users, and I hope that will
get more feedback on the feature.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/experimental/synchronized_value: New file.
	* testsuite/experimental/synchronized_value.cc: New test.
2023-02-16 14:38:38 +00:00
Jonathan Wakely 38f321793a libstdc++: Fix name of <experimental/optional> in comment
libstdc++-v3/ChangeLog:

	* include/experimental/optional: Fix header name in comment.
2023-02-16 14:38:38 +00:00
Jonathan Wakely 4024f39941 libstdc++: Enable CTAD for std::basic_format_args (LWG 3810)
This was just approved in Issaquah.

libstdc++-v3/ChangeLog:

	* include/std/format (__format::_Arg_store): New class template.
	(basic_format_args): Remove nested type _Store and add deduction
	guide from _Arg_store.
	(basic_format_arg, make_format_args): Adjust.
	* testsuite/std/format/arguments/lwg3810.cc: New test.
2023-02-16 14:38:38 +00:00