aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
AgeCommit message (Collapse)AuthorFilesLines
2024-08-03libstdc++: Fix __cpp_lib_chrono for old std::string ABIJonathan Wakely2-1/+2
The <chrono> header is incomplete for the old std::string ABI, because std::chrono::tzdb is only defined for the new ABI. The feature test macro advertising full C++20 support should not be defined for the old ABI. libstdc++-v3/ChangeLog: * include/bits/version.def (chrono): Add cxx11abi = yes. * include/bits/version.h: Regenerate. * testsuite/std/time/syn_c++20.cc: Adjust expected value for the feature test macro. (cherry picked from commit f906b107634bfac29676e7fcf364d0ca7ceed666)
2024-08-01libstdc++: fix uses of explicit object parameter [PR116038]Patrick Palka2-6/+9
The type of an implicit object parameter is always the current class. For an explicit object parameter however, its deduced type can be a derived class of the current class. So when combining multiple implicit-object overloads into a single explicit-object overload we need to account for this possibility. For example when accessing a member of the current class through an explicit object parameter, it may now be a derived class from which the member is not accessible, as in the below testcases. This pitfall is discussed[1] in the deducing this paper. The general solution is to cast the explicit object parameter to (a reference to) the current class rather than e.g. using std::forward which preserves the deduced type. This patch corrects the existing problematic uses of explicit object parameters in the library, all of which forward the parameter via std::forward, to instead cast the parameter to the current class via our __like_t alias template. Note that unlike the paper's like_t, ours always returns a reference so we can just write __like_t<Self, B>(self) instead of (_like_t<Self, B>&&)self as the paper does. [1]: https://wg21.link/P0847#name-lookup-within-member-functions (and the section after that) PR libstdc++/116038 libstdc++-v3/ChangeLog: * include/std/functional (_Bind_front::operator()): Use __like_t instead of std::forward when forwarding __self. (_Bind_back::operator()): Likewise. * include/std/ranges (_Partial::operator()): Likewise. (_Pipe::operator()): Likewise. * testsuite/20_util/function_objects/bind_back/116038.cc: New test. * testsuite/20_util/function_objects/bind_front/116038.cc: New test. * testsuite/std/ranges/adaptors/116038.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> (cherry picked from commit 1066a95aa33eee2d2bd9c8324f34dedb967f338c)
2024-08-01libstdc++: Add [[nodiscard]] to some std::locale functionsJonathan Wakely2-1/+8
libstdc++-v3/ChangeLog: * include/bits/locale_classes.h (locale::combine) (locale::name, locale::operator==, locale::operator!=) (locale::operator(), locale::classic): Add nodiscard attribute. * include/bits/locale_classes.tcc (has_facet, use_facet): Likewise. * testsuite/22_locale/locale/cons/12438.cc: Add dg-warning for nodiscard diagnostic. * testsuite/22_locale/locale/cons/2.cc: Cast use_facet expression to void, to suppress diagnostic. * testsuite/22_locale/locale/cons/unicode.cc: Likewise. * testsuite/22_locale/locale/operations/2.cc: Add dg-warning. (cherry picked from commit fd1a674ff5f37e74fbbdcdb85d78399e963eb401)
2024-08-01libstdc++: Add missing constexpr to __atomic_impl::__clear_paddingDeev Patel1-1/+1
This is called from the std::atomic<floating-point-type> constructor, which needs to be usable in constant expressions. libstdc++-v3/ChangeLog: * include/bits/atomic_base.h (__atomic_impl::__clear_padding): Add missing constexpr specifier. * testsuite/29_atomics/atomic_float/constinit.cc: New test. Co-authored-by: Jonathan Wakely <jwakely@redhat.com> (cherry picked from commit ae91b5dd14920ff9671db8ff80c0d763d25f977f)
2024-08-01libstdc++: Fix std::tr2::dynamic_bitset shift operations [PR115399]Jonathan Wakely2-8/+3
The shift operations for dynamic_bitset fail to zero out words where the non-zero bits were shifted to a completely different word. For a right shift we don't need to sanitize the unused bits in the high word, because we know they were already clear and a right shift doesn't change that. libstdc++-v3/ChangeLog: PR libstdc++/115399 * include/tr2/dynamic_bitset (operator>>=): Remove redundant call to _M_do_sanitize. * include/tr2/dynamic_bitset.tcc (_M_do_left_shift): Zero out low bits in words that should no longer be populated. (_M_do_right_shift): Likewise for high bits. * testsuite/tr2/dynamic_bitset/pr115399.cc: New test. (cherry picked from commit bd3a312728fbf8c35a09239b9180269f938f872e)
2024-08-01libstdc++: Remove std::basic_format_args default constructor (LWG 4106)Jonathan Wakely1-2/+0
There's no valid use case for default constructing this type, so the committee approved removing the default constructor. libstdc++-v3/ChangeLog: * include/std/format (basic_format_args): Remove default constructor, as per LWG 4106. * testsuite/std/format/arguments/args.cc: Check it isn't default constructible. (cherry picked from commit 5be55447e256302324f38f04316a437909ae5847)
2024-08-01libstdc++: Make std::basic_format_context non-copyable [PR114387]Jonathan Wakely1-1/+6
Users are not supposed to create objects of this type, and there's no reason it needs to be copyable. LWG 4061 makes it non-copyable and non-default constructible. libstdc++-v3/ChangeLog: PR libstdc++/114387 * include/std/format (basic_format_context): Define copy operations as deleted, as per LWG 4061. * testsuite/std/format/context.cc: New test. (cherry picked from commit d8cd8521185436ea45ed48c5dd481277e9b8a98d)
2024-08-01libstdc++: Make std::any_cast<void> ill-formed (LWG 3305)Jonathan Wakely1-0/+8
LWG 3305 was approved earlier this year in Tokyo. We need to give an error if using std::any_cast<void>, but std::any_cast<void()> is valid (but always returns null). libstdc++-v3/ChangeLog: * include/std/any (any_cast(any*), any_cast(const any*)): Add static assertion to reject void types, as per LWG 3305. * testsuite/20_util/any/misc/lwg3305.cc: New test. (cherry picked from commit 466ee78e3e975627440992dac67973ee314a0551)
2024-08-01libstdc++: Define __cpp_lib_ranges in <algorithm>Jonathan Wakely1-0/+1
The __cpp_lib_ranges macro is missing from <algorithm>. libstdc++-v3/ChangeLog: * include/std/algorithm: Define __glibcxx_want_ranges. * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Check feature test macro in C++20 mode. (cherry picked from commit 77e84dc4e4e60ec5e7d6d1124e226452aa558108)
2024-08-01libstdc++: Use direct-initialization for std::vector<bool>'s allocator ↵Jonathan Wakely1-1/+1
[PR115854] The consensus in the standard committee is that this change shouldn't be necessary, and the Allocator requirements should require conversions between rebound allocators to be implicit. But we can make it work for now anyway. libstdc++-v3/ChangeLog: PR libstdc++/115854 * include/bits/stl_bvector.h (_Bvector_base): Convert allocator to rebound type explicitly. * testsuite/23_containers/vector/allocator/115854.cc: New test. * testsuite/23_containers/vector/bool/allocator/115854.cc: New test. (cherry picked from commit c5efc6eca8e3eee7038ae218cf7e2dbe9ed9d82a)
2024-08-01libstdc++: Use __glibcxx_ranges_as_const to guard P2278R4 changesJonathan Wakely2-9/+9
The P2278R4 additions for C++23 are currently guarded by a check for __cplusplus > 202002L but can use __glibcxx_ranges_as_const instead. libstdc++-v3/ChangeLog: * include/bits/ranges_base.h (const_iterator_t): Change preprocessor condition to use __glibcxx_ranges_as_const. (const_sentinel_t, range_const_reference_t): Likewise. (__access::__possibly_const_range, cbegin, cend, crbegin) (crend, cdata): Likewise. * include/bits/stl_iterator.h (iter_const_reference_t) (basic_const_iterator, const_iterator, const_sentinel) (make_const_iterator): Likewise. (cherry picked from commit 0755b2304bac9579fd5da337da8f861ccb1b042b)
2024-08-01libstdc++: Use reserved form of [[__likely__]] in <variant>Jonathan Wakely1-1/+1
We should not use [[unlikely]] before C++20, so use [[__unlikely__]] instead. libstdc++-v3/ChangeLog: * include/std/variant (_Variant_storage::_M_reset): Use __unlikely__ form of attribute instead of unlikely. (cherry picked from commit 9f1cd51766f251aafe0f1b898892f79855892729)
2024-08-01libstdc++: Fix <ostream> and <istream> for -std=gnu++14 -fconcepts [PR116070]Jonathan Wakely2-2/+2
This questionable combination of flags causes a number of errors. The ones in the rvalue stream overloads need to be fixed in the gcc-14 branch so I'm committing it separately to simplify backporting. libstdc++-v3/ChangeLog: PR libstdc++/116070 * include/std/istream: Check feature test macro before using is_class_v and is_same_v. * include/std/ostream: Likewise. (cherry picked from commit 6c22fe418cff57dad712c4b950638e6e2d09bd9c)
2024-08-01libstdc++: Fix std::vector<bool> for -std=gnu++14 -fconcepts [PR116070]Jonathan Wakely1-1/+1
This questionable combination of flags causes a number of errors. This one in std::vector<bool> needs to be fixed in the gcc-13 branch so I'm committing it separately to simplify backporting. libstdc++-v3/ChangeLog: PR libstdc++/116070 * include/bits/stl_bvector.h: Check feature test macro before using is_default_constructible_v. (cherry picked from commit 5fc9c40fea2481e56bf7bcc994cb40c71e28abb8)
2024-07-12libstdc++: Fix unwanted #pragma messages from PSTL headers [PR113376]Jonathan Wakely1-1/+1
When we rebased the PSTL on upstream, in r14-2109-g3162ca09dbdc2e, a change to how _PSTL_USAGE_WARNINGS is set was missed out, but the change to how it's tested was included. This means that the macro is always defined, so testing it with #ifdef (instead of using #if to test its value) doesn't work as intended. Revert the test to use #if again, since that part of the upstream change was unnecessary in the first place (the macro is always defined, so there's no need to use #ifdef to avoid -Wundef warnings). libstdc++-v3/ChangeLog: PR libstdc++/113376 * include/pstl/pstl_config.h: Use #if instead of #ifdef to test the _PSTL_USAGE_WARNINGS macro. (cherry picked from commit 99a1fe6c12c733fe4923a75a79d09a66ff8abcec)
2024-07-12libstdc++: Fix std::to_array for trivial-ish types [PR115522]Jonathan Wakely1-2/+6
Due to PR c++/85723 the std::is_trivial trait is true for types with a deleted default constructor, so the use of std::is_trivial in std::to_array is not sufficient to ensure the type can be trivially default constructed then filled using memcpy. I also forgot that a type with a deleted assignment operator can still be trivial, so we also need to check that it's assignable because the is_constant_evaluated() path can't use memcpy. Replace the uses of std::is_trivial with std::is_trivially_copyable (needed for memcpy), std::is_trivially_default_constructible (needed so that the default construction is valid and does no work) and std::is_copy_assignable (needed for the constant evaluation case). libstdc++-v3/ChangeLog: PR libstdc++/115522 * include/std/array (to_array): Workaround the fact that std::is_trivial is not sufficient to check that a type is trivially default constructible and assignable. * testsuite/23_containers/array/creation/115522.cc: New test. (cherry picked from commit 510ce5eed69ee1bea9c2c696fe3b2301e16d1486)
2024-07-09libstdc++: Fix _Atomic(T) macro in <stdatomic.h> [PR115807]Jonathan Wakely1-1/+1
The definition of the _Atomic(T) macro needs to refer to ::std::atomic, not some other std::atomic relative to the current namespace. libstdc++-v3/ChangeLog: PR libstdc++/115807 * include/c_compatibility/stdatomic.h (_Atomic): Ensure it refers to std::atomic in the global namespace. * testsuite/29_atomics/headers/stdatomic.h/115807.cc: New test. (cherry picked from commit 40d234dd6439e8c8cfbf3f375a61906aed35c80d)
2024-06-28libstdc++: Fix std::format for chrono::duration with unsigned rep [PR115668]Jonathan Wakely1-1/+4
Using std::chrono::abs is only valid if numeric_limits<rep>::is_signed is true, so using it unconditionally made it ill-formed to format a duration with an unsigned rep. The duration formatter might as well negate the duration itself instead of using chrono::abs, because it already needs to check for a negative value. libstdc++-v3/ChangeLog: PR libstdc++/115668 * include/bits/chrono_io.h (formatter<duration<R,P, C>::format): Do not use chrono::abs. * testsuite/20_util/duration/io.cc: Check formatting a duration with unsigned rep. (cherry picked from commit dafa750c8a6f0a088677871bfaad054881737ab1)
2024-06-20libstdc++: Fix find_last_set(simd_mask) to ignore padding bitsMatthias Kretz1-13/+13
With the change to the AVX512 find_last_set implementation, the change to AVX512 operator!= is unnecessary. However, the latter was not producing optimal code and unnecessarily set the padding bits. In theory, the compiler could determine that with the new != implementation, the bit operation for clearing the padding bits is a no-op and can be elided. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/115454 * include/experimental/bits/simd_x86.h (_S_not_equal_to): Use neq comparison instead of bitwise negation after eq. (_S_find_last_set): Clear unused high bits before computing bit_width. * testsuite/experimental/simd/pr115454_find_last_set.cc: New test. (cherry picked from commit 1340ddea0158de3f49aeb75b4013e5fc313ff6f4)
2024-06-10libstdc++: Fix simd<char> conversion for -fno-signed-char for ClangMatthias Kretz1-18/+27
The special case for Clang in the trait producing a signed integer type lead to the trait returning 'char' where it should have been 'signed char'. This workaround was introduced because on Clang the return type of vector compares was not convertible to '_SimdWrapper< __int_for_sizeof_t<...' unless '__int_for_sizeof_t<char>' was an alias for 'char'. In order to not rewrite the complete mask type code (there is code scattered around the implementation assuming signed integers), this needs to be 'signed char'; so the special case for Clang needs to be removed. The conversion issue is now solved in _SimdWrapper, which now additionally allows conversion from vector types with compatible integral type. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/115308 * include/experimental/bits/simd.h (__int_for_sizeof): Remove special cases for __clang__. (_SimdWrapper): Change constructor overload set to allow conversion from vector types with integral conversions via bit reinterpretation. (cherry picked from commit 8e36cf4c5c9140915d0019999db132a900b48037)
2024-06-10libstdc++: Avoid MMX return types from __builtin_shufflevectorMatthias Kretz1-11/+28
This resolves a regression on i686 that was introduced with r15-429-gfb1649f8b4ad50. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/115247 * include/experimental/bits/simd.h (__as_vector): Don't use vector_size(8) on __i386__. (__vec_shuffle): Never return MMX vectors, widen to 16 bytes instead. (concat): Fix padding calculation to pick up widening logic from __as_vector. (cherry picked from commit 241a6cc88d866fb36bd35ddb3edb659453d6322e)
2024-06-10libstdc++: Use __builtin_shufflevector for simd split and concatMatthias Kretz3-192/+125
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/114958 * include/experimental/bits/simd.h (__as_vector): Return scalar simd as one-element vector. Return vector from single-vector fixed_size simd. (__vec_shuffle): New. (__extract_part): Adjust return type signature. (split): Use __extract_part for any split into non-fixed_size simds. (concat): If the return type stores a single vector, use __vec_shuffle (which calls __builtin_shufflevector) to produce the return value. * include/experimental/bits/simd_builtin.h (__shift_elements_right): Removed. (__extract_part): Return single elements directly. Use __vec_shuffle (which calls __builtin_shufflevector) to for all non-trivial cases. * include/experimental/bits/simd_fixed_size.h (__extract_part): Return single elements directly. * testsuite/experimental/simd/pr114958.cc: New test. (cherry picked from commit fb1649f8b4ad5043dd0e65e4e3a643a0ced018a9)
2024-06-04libstdc++: Only define std::span::at for C++26 [PR115335]Jonathan Wakely1-0/+2
In r14-5689-g1fa85dcf656e2f I added std::span::at and made the correct changes to the __cpp_lib_span macro (with tests for the correct value in C++20/23/26). But I didn't make the declaration of std::span::at actually depend on the macro, so it was defined for C++20 and C++23, not only for C++26. This fixes that oversight. libstdc++-v3/ChangeLog: PR libstdc++/115335 * include/std/span (span::at): Guard with feature test macro. (cherry picked from commit 2197814011eec75022aa8550f10621409b69d4a1)
2024-06-03libstdc++: Fix -Wstringop-overflow warning coming from std::vector [PR109849]François Dumont1-0/+5
libstdc++-v3/ChangeLog: PR libstdc++/109849 * include/bits/vector.tcc (std::vector<>::_M_range_insert(iterator, _FwdIt, _FwdIt, forward_iterator_tag))[__cplusplus < 201103L]: Add __builtin_unreachable expression to tell the compiler that the allocated buffer is large enough to receive current elements plus the elements of the range to insert. (cherry picked from commit 0426be454448f8cfb9db21f4f669426afb7b57c8)
2024-05-28libstdc++: Guard use of sized deallocation [PR114940]Jonathan Wakely3-4/+13
Clang does not enable -fsized-deallocation by default, which means it can't compile our <stacktrace> and <generator> headers. Make the __cpp_lib_generator macro depend on the compiler-defined __cpp_sized_deallocation macro, and change <stacktrace> to use unsized deallocation when __cpp_sized_deallocation isn't defined. libstdc++-v3/ChangeLog: PR libstdc++/114940 * include/bits/version.def (generator): Depend on __cpp_sized_deallocation. * include/bits/version.h: Regenerate. * include/std/stacktrace (_GLIBCXX_SIZED_DELETE): New macro. (basic_stacktrace::_Impl::_M_deallocate): Use it. (cherry picked from commit b2fdd508d7e63158e9d2a6dd04f901d02900def3)
2024-05-22libstdc++: Implement std::formatter<std::thread::id> without <sstream> ↵Jonathan Wakely2-11/+43
[PR115099] The std::thread::id formatter uses std::basic_ostringstream without including <sstream>, which went unnoticed because the test for it uses a stringstream to check the output is correct. The fix implemented here is to stop using basic_ostringstream for formatting thread::id and just use std::format instead. As a drive-by fix, the formatter specialization is constrained to require that the thread::id::native_handle_type can be formatted, to avoid making the formatter ill-formed if the pthread_t type is not a pointer or integer. Since non-void pointers can't be formatted, ensure that we convert pointers to const void* for formatting. Make a similar change to the existing operator<< overload so that in the unlikely case that pthread_t is a typedef for char* we don't treat it as a null-terminated string when inserting into a stream. libstdc++-v3/ChangeLog: PR libstdc++/115099 * include/bits/std_thread.h: Declare formatter as friend of thread::id. * include/std/thread (operator<<): Convert non-void pointers to void pointers for output. (formatter): Add constraint that thread::native_handle_type is a pointer or integer. (formatter::format): Reimplement without basic_ostringstream. * testsuite/30_threads/thread/id/output.cc: Check output compiles before <sstream> has been included. (cherry picked from commit 1a5e4dd83788ea4c049d354d83ad58a6a3d747e6)
2024-05-17libstdc++: Fix typo in _Grapheme_cluster_view::_Iterator [PR115119]Jonathan Wakely1-2/+4
libstdc++-v3/ChangeLog: PR libstdc++/115119 * include/bits/unicode.h (_Iterator::operator++(int)): Fix typo in increment expression. * testsuite/ext/unicode/grapheme_view.cc: Check post-increment on view's iterator. (cherry picked from commit c9e05b03c18e898be604ab90401476e9c473cc52)
2024-05-14libstdc++: Fix typo in std::stacktrace::max_size [PR115063]Jonathan Wakely1-1/+1
libstdc++-v3/ChangeLog: PR libstdc++/115063 * include/std/stacktrace (basic_stacktrace::max_size): Fix typo in reference to _M_alloc member. * testsuite/19_diagnostics/stacktrace/stacktrace.cc: Check max_size() compiles. (cherry picked from commit dd9677f3343ca2a4b4aab9428b8129774accac29)
2024-05-14libstdc++: Guard uses of is_pointer_interconvertible_v [PR114891]Jonathan Wakely1-0/+8
This type trait isn't supported by Clang 18. It's only used in static assertions, so they can just be omitted if the trait isn't available. libstdc++-v3/ChangeLog: PR libstdc++/114891 * include/std/generator: Check feature test macro before using is_pointer_interconvertible_v. (cherry picked from commit 1fbe1a50d86df11f434351cf62461a32747f9710)
2024-05-14libstdc++: Fix handling of incomplete UTF-8 sequences in _Unicode_viewJonathan Wakely1-13/+11
Eddie Nolan reported to me that _Unicode_view was not correctly implementing the substitution of ill-formed subsequences with U+FFFD, due to failing to increment the counter when the iterator reaches the end of the sequence before a multibyte sequence is complete. As a result, the incomplete sequence was not completely consumed, and then the remaining character was treated as another ill-formed sequence, giving two U+FFFD characters instead of one. To avoid similar mistakes in future, this change introduces a lambda that increments the iterator and the counter together. This ensures the counter is always incremented when the iterator is incremented, so that we always know how many characters have been consumed. libstdc++-v3/ChangeLog: * include/bits/unicode.h (_Unicode_view::_M_read_utf8): Ensure count of characters consumed is correct when the end of the input is reached unexpectedly. * testsuite/ext/unicode/view.cc: Test incomplete UTF-8 sequences. (cherry picked from commit 3f04f3939ea0ac8fdd766a60655d29de2ffb44e5)
2024-05-14libstdc++: Fix <memory> for -std=c++23 -ffreestanding [PR114866]Jonathan Wakely1-0/+10
std::shared_ptr isn't declared for freestanding, so guard uses of it with #if _GLIBCXX_HOSTED in <bits/out_ptr.h>. libstdc++-v3/ChangeLog: PR libstdc++/114866 * include/bits/out_ptr.h [!_GLIBCXX_HOSTED]: Don't refer to shared_ptr, __shared_ptr or __is_shred_ptr. * testsuite/20_util/headers/memory/114866.cc: New test. (cherry picked from commit 9927059bb88e966e0a45f09e4fd1193f93df708f)
2024-04-30libstdc++: Do not apply localized formatting to NaN and inf [PR114863]Jonathan Wakely1-1/+1
We don't want to add grouping to strings like "-inf", and there is no radix character to replace either. libstdc++-v3/ChangeLog: PR libstdc++/114863 * include/std/format (__formatter_fp::format): Only use _M_localized for finite values. * testsuite/std/format/functions/format.cc: Check localized formatting of NaN and initiny. (cherry picked from commit 7501c0a397fcf609a1ff5f083746b6330b89ee11)
2024-04-25libstdc++: Fix typo in Doxygen commentJonathan Wakely1-1/+1
libstdc++-v3/ChangeLog: * include/std/chrono (tzdb_list): Fix typo in Doxygen comment.
2024-04-25libstdc++: Add comment to #include in <variant>Jonathan Wakely1-1/+1
It's not obvious why <variant> needs <bits/parse_numbers.h> so add a comment to it. libstdc++-v3/ChangeLog: * include/std/variant: Add comment to #include.
2024-04-22libstdc++: Fix conversion of simd to vector builtinMatthias Kretz1-1/+1
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/114803 * include/experimental/bits/simd_builtin.h (_SimdBase2::operator __vector_type_t): There is no __builtin() function in _SimdWrapper, instead use its conversion operator. * testsuite/experimental/simd/pr114803_vecbuiltin_cvt.cc: New test.
2024-04-22libstdc++: Silence irrelevant warnings in <experimental/simd>Matthias Kretz2-3/+8
Avoid -Wnarrowing in C code; -Wtautological-compare in unconditional static_assert (necessary for faking a dependency on a template parameter) Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h: Ignore -Wnarrowing for arm_neon.h. (__int_for_sizeof): Replace tautological compare with checking for invalid template parameter value. * include/experimental/bits/simd_builtin.h (__extract_part): Remove tautological compare by combining two static_assert.
2024-04-19libstdc++: Simplify constraints on <=> for std::reference_wrapperJonathan Wakely1-5/+11
Instead of constraining these overloads in terms of synth-three-way we can just check that the value_type is less-than-comparable, which is what synth-three-way's constraints check. The reason that I implemented these with constraints has now been filed as LWG 4071, so add a comment about that too. libstdc++-v3/ChangeLog: * include/bits/refwrap.h (operator<=>): Simplify constraints.
2024-04-17libstdc++: Implement "Printing blank lines with println" for C++23Jonathan Wakely2-0/+26
This was recently approved for C++26 at the Tokyo meeting. As suggested by Stephan T. Lavavej, I'm defining it as an extension for C++23 mode (when std::print and std::prinln were first added) rather than as a new C++26 feature. Both MSVC and libc++ have agreed to do this too. libstdc++-v3/ChangeLog: * include/std/ostream (println(ostream&)): Define new overload. * include/std/print (println(FILE*), println()): Likewise. * testsuite/27_io/basic_ostream/print/2.cc: New test. * testsuite/27_io/print/1.cc: Remove unused header. * testsuite/27_io/print/3.cc: New test.
2024-04-17libstdc++: Add include guard to simd-internal headerMatthias Kretz1-0/+4
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/numeric_traits.h: Add include guard.
2024-04-17libstdc++: Avoid ill-formed types on ARMMatthias Kretz1-2/+2
This resolves failing tests in check-simd. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/114750 * include/experimental/bits/simd_builtin.h (_SimdImplBuiltin::_S_load, _S_store): Fall back to copying scalars if the memory type cannot be vectorized for the target.
2024-04-15libstdc++: Add std::reference_wrapper comparison operators for C++26Jonathan Wakely4-0/+64
This C++26 change was just approved in Tokyo, in P2944R3. It adds operator== and operator<=> overloads to std::reference_wrapper. The operator<=> overloads in the paper cause compilation errors for any type without <=> so they're implemented here with deduced return types and constrained by a requires clause. libstdc++-v3/ChangeLog: * include/bits/refwrap.h (reference_wrapper): Add comparison operators as proposed by P2944R3. * include/bits/version.def (reference_wrapper): Define. * include/bits/version.h: Regenerate. * include/std/functional: Enable feature test macro. * testsuite/20_util/reference_wrapper/compare.cc: New test.
2024-04-15libstdc++: Heterogeneous std::pair comparisons [PR113386]Jonathan Wakely1-8/+24
I'm only treating this as a DR for C++20 for now, because it's less work and only requires changes to operator== and operator<=>. To do this for older standards would require changes to the six relational operators used pre-C++20. libstdc++-v3/ChangeLog: PR libstdc++/113386 * include/bits/stl_pair.h (operator==, operator<=>): Support heterogeneous comparisons, as per LWG 3865. * testsuite/20_util/pair/comparison_operators/lwg3865.cc: New test.
2024-04-10libstdc++: Fix build for targets without FP std::from_chars [PR114633]Jonathan Wakely1-0/+4
If the faster std::from_chars is not supported for floating-point types then just extract the value from the stream using operator>>. This fixes a build error for targets where __cpp_lib_to_chars is not defined. libstdc++-v3/ChangeLog: PR libstdc++/114633 * include/bits/chrono_io.h (_Parser::operator()) <'S'>: Use stream extraction if std::from_chars is not available.
2024-04-08libstdc++: Use char for _Utf8_view if char8_t isn't available [PR114519]Jonathan Wakely1-0/+3
Instead of just omitting the definition of __unicode::_Utf8_view when char8_t is disabled, we can make it use char instead. libstdc++-v3/ChangeLog: PR libstdc++/114519 * include/bits/unicode.h (_Utf8_view) [!__cpp_char8_t]: Define using char instead of char8_t. * testsuite/ext/unicode/view.cc: Use u8""sv literals to create string views, instead of std::u8string_view.
2024-04-03libstdc++: Reverse arguments in constraint for std::optional's <=> [PR104606]Jonathan Wakely1-1/+1
This is a workaround for a possible compiler bug that causes constraint recursion in the operator<=>(const optional<T>&, const U&) overload. libstdc++-v3/ChangeLog: PR libstdc++/104606 * include/std/optional (operator<=>(const optional<T>&, const U&)): Reverse order of three_way_comparable_with template arguments. * testsuite/20_util/optional/relops/104606.cc: New test.
2024-04-02libstdc++: Guard uses of char8_t with __cpp_char8_t [PR114519]Jonathan Wakely1-3/+7
libstdc++-v3/ChangeLog: PR libstdc++/114519 * include/bits/unicode.h (_Utf8_view): Guard with check for char8_t being enabled. (__literal_encoding_is_unicode): Guard use of char8_t with check for it being enabled. * testsuite/std/format/functions/114519.cc: New test.
2024-04-02libstdc++: Allow adjacent __maybe_present_t<false, ...> fields to overlapPatrick Palka1-5/+8
Currently __maybe_present_t<false, T> maps to the same empty class type independent of T. This is suboptimal because it means adjacent __maybe_present_t<false, ...> members with the [[no_unique_address]] attribute can't overlap even if the conditionally present types are different. This patch turns this empty class type into a template parameterized by the conditionally present type, so that [[no_unique_address]] __maybe_present_t<false, T> _M_a; [[no_unique_address]] __maybe_present_t<false, U> _M_b; now overlap if T and U are different. This patch goes a step further and also adds an optional integer discriminator parameter to allow for overlapping when T and U are the same. libstdc++-v3/ChangeLog: * include/std/ranges (ranges::__detail::_Empty): Rename to ... (ranges::__detail::_Absent): ... this. Turn into a template parameterized by the absent type _Tp and discriminator _Disc. (ranges::__detail::__maybe_present_t): Add an optional discriminator parameter. (slide_view::_M_cached_begin): Pass a discriminator argument to __maybe_present_t. (slide_view::_M_cached_end): Likewise. * testsuite/std/ranges/adaptors/sizeof.cc: Verify the size of slide_view<V> is 3 instead 4 pointers. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-03-27libstdc++: Add masked ++/-- implementation for sizeof < 16Matthias Kretz1-10/+14
This resolves further failures (-Wreturn-type warnings) and test failures for where-* tests targeting AVX-512. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_x86.h (_S_masked_unary): Cast inputs < 16 bytes to 16 byte vectors before calling the right subtraction builtin. Before returning, truncate to the return vector type.
2024-03-27libstdc++: Fix call signature of builtins from masked ++/--Matthias Kretz1-3/+9
This resolves failures in the "expensive" where-* test of check-simd when targeting AVX-512. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_x86.h (_S_masked_unary): Call the 4- and 8-byte variants of __builtin_ia32_subp[ds] without rounding direction argument.
2024-03-27libstdc++: add ARM SVE support to std::experimental::simdSrinivas Yadav Singanaboina9-104/+2152
libstdc++-v3/ChangeLog: * include/Makefile.am: Add simd_sve.h. * include/Makefile.in: Add simd_sve.h. * include/experimental/bits/simd.h: Add new SveAbi. * include/experimental/bits/simd_builtin.h: Use __no_sve_deduce_t to support existing Neon Abi. * include/experimental/bits/simd_converter.h: Convert sequentially when sve is available. * include/experimental/bits/simd_detail.h: Define sve specific macro. * include/experimental/bits/simd_math.h: Fallback frexp to execute sequntially when sve is available, to handle fixed_size_simd return type that always uses sve. * include/experimental/simd: Include bits/simd_sve.h. * testsuite/experimental/simd/tests/bits/main.h: Enable testing for sve128, sve256, sve512. * include/experimental/bits/simd_sve.h: New file. Signed-off-by: Srinivas Yadav Singanaboina <vasu.srinivasvasu.14@gmail.com>