aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
AgeCommit message (Collapse)Author
2023-05-29Update ChangeLog and version files for releasereleases/gcc-11.4.0Jakub Jelinek
2023-05-26Daily bump.GCC Administrator
2023-05-25libstdc++: Add missing constexpr to simdMatthias Kretz
The constexpr API is only available with -std=gnu++XX (and proposed for C++26). The proposal is to have the complete simd API usable in constant expressions. This patch resolves several issues with using simd in constant expressions. Issues why constant_evaluated branches are necessary: * subscripting vector builtins is not allowed in constant expressions * if the implementation needs/uses memcpy * if the implementation would otherwise call SIMD intrinsics/builtins Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109261 * include/experimental/bits/simd.h (_SimdWrapper::_M_set): Avoid vector builtin subscripting in constant expressions. (resizing_simd_cast): Avoid memcpy if constant_evaluated. (const_where_expression, where_expression, where) (__extract_part, simd_mask, _SimdIntOperators, simd): Add either _GLIBCXX_SIMD_CONSTEXPR (on public APIs), or constexpr (on internal APIs). * include/experimental/bits/simd_builtin.h (__vector_permute) (__vector_shuffle, __extract_part, _GnuTraits::_SimdCastType1) (_GnuTraits::_SimdCastType2, _SimdImplBuiltin) (_MaskImplBuiltin::_S_store): Add constexpr. (_CommonImplBuiltin::_S_store_bool_array) (_SimdImplBuiltin::_S_load, _SimdImplBuiltin::_S_store) (_SimdImplBuiltin::_S_reduce, _MaskImplBuiltin::_S_load): Add constant_evaluated case. * include/experimental/bits/simd_fixed_size.h (_S_masked_load): Reword comment. (__tuple_element_meta, __make_meta, _SimdTuple::_M_apply_r) (_SimdTuple::_M_subscript_read, _SimdTuple::_M_subscript_write) (__make_simd_tuple, __optimize_simd_tuple, __extract_part) (__autocvt_to_simd, _Fixed::__traits::_SimdBase) (_Fixed::__traits::_SimdCastType, _SimdImplFixedSize): Add constexpr. (_SimdTuple::operator[], _M_set): Add constexpr and add constant_evaluated case. (_MaskImplFixedSize::_S_load): Add constant_evaluated case. * include/experimental/bits/simd_scalar.h: Add constexpr. * include/experimental/bits/simd_x86.h (_CommonImplX86): Add constexpr and add constant_evaluated case. (_SimdImplX86::_S_equal_to, _S_not_equal_to, _S_less) (_S_less_equal): Value-initialize to satisfy constexpr evaluation. (_MaskImplX86::_S_load): Add constant_evaluated case. (_MaskImplX86::_S_store): Add constexpr and constant_evaluated case. Value-initialize local variables. (_MaskImplX86::_S_logical_and, _S_logical_or, _S_bit_not) (_S_bit_and, _S_bit_or, _S_bit_xor): Add constant_evaluated case. * testsuite/experimental/simd/pr109261_constexpr_simd.cc: New test. (cherry picked from commit da579188807ede4ee9466d0b5bf51559c96a0b51)
2023-05-25libstdc++: Fix type of first argument to vec_cntm callMatthias Kretz
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109949 * include/experimental/bits/simd.h (__intrinsic_type): If __ALTIVEC__ is defined, map gnu::vector_size types to their corresponding __vector T types without losing unsignedness of integer types. Also prefer long long over long. * include/experimental/bits/simd_ppc.h (_S_popcount): Cast mask object to the expected unsigned vector type. (cherry picked from commit efd2b55d8562c6e80cb7ee8b9b1f9418f0c00cd9)
2023-05-25libstdc++: Fix SFINAE for __is_intrinsic_type on ARMMatthias Kretz
On ARM NEON doesn't support double, so __is_intrinsic_type_v<double, whatever> should say false (instead of being ill-formed). Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109261 * include/experimental/bits/simd.h (__intrinsic_type): Specialize __intrinsic_type<double, 8> and __intrinsic_type<double, 16> in any case, but provide the member type only with __aarch64__. (cherry picked from commit aa8b363171a95b8f867a74f29c75f9577e9087e1)
2023-05-25libstdc++: Add missing constexpr to simd_neonMatthias Kretz
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109261 * include/experimental/bits/simd_neon.h (_S_reduce): Add constexpr and make NEON implementation conditional on not __builtin_is_constant_evaluated. (cherry picked from commit b0a483b0a011f9cbc8b25053eae809c77dae2a12)
2023-05-25libstdc++: Resolve -Wunused-variable warnings in stdx::simd and testsMatthias Kretz
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd_builtin.h (_S_fpclassify): Move __infn into #ifdef'ed block. * testsuite/experimental/simd/tests/fpclassify.cc: Declare constants only when used. * testsuite/experimental/simd/tests/frexp.cc: Likewise. * testsuite/experimental/simd/tests/logarithm.cc: Likewise. * testsuite/experimental/simd/tests/trunc_ceil_floor.cc: Likewise. * testsuite/experimental/simd/tests/ldexp_scalbn_scalbln_modf.cc: Move totest and expect1 into #ifdef'ed block. (cherry picked from commit a7129e82bed1bd4f513fc3c3f401721e2c96a865)
2023-05-25libstdc++: Add missing trait is_simd_flag_typeMatthias Kretz
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h (is_simd_flag_type): New. (_IsSimdFlagType): New. (copy_from, copy_to, load ctors): Constrain _Flags using _IsSimdFlagType. (cherry picked from commit 97383b4116ea63486eb5bfb0a7140871bed75fb4)
2023-05-25libstdc++: Fix operator% implementation for ClangMatthias Kretz
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. (cherry picked from commit 1a62008123694b2ac07f28e25fc6e5ff371925f5)
2023-05-25libstdc++: Fix simd compilation with ClangMatthias Kretz
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. (cherry picked from commit 8ff3ca2d94721fab78f167d435d4ea4fa4fdca6a)
2023-05-25libstdc++: Fix formattingMatthias Kretz
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. (cherry picked from commit b31186e589caee43ac5720a538d9a41ebf514e81)
2023-05-25libstdc++: Always-inline most of non-cmath fixed_size implementationMatthias Kretz
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. (cherry picked from commit e37b04328ae68f91efe1fb2c5de9122be34bc74a)
2023-05-25libstdc++: More efficient masked inc-/decrement implementationMatthias Kretz
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. (cherry picked from commit 6ce55180d494b616e2e3e68ffedfe9007e42ca06)
2023-05-25libstdc++: Test that integral simd reductions are preciseMatthias Kretz
Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * testsuite/experimental/simd/tests/reductions.cc: Introduce max_distance as the type-dependent max error. (cherry picked from commit 8fda668e0919af9ceda9435f02a1708b375b2913)
2023-05-25libstdc++: Fix simd build failure on clangMatthias Kretz
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__. (cherry picked from commit 92c47b15d5af3e7f93d11ad69a45b6d1cb8661c5)
2023-05-25libstdc++: Annotate most lambdas with always_inlineMatthias Kretz
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. (cherry picked from commit 53b55701aed6896f456cdec7997ac6bbef1d6074)
2023-05-23Daily bump.GCC Administrator
2023-05-21libstdc++: Implement P2520R0 changes to move_iterator's iterator_conceptPatrick Palka
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. (cherry picked from commit 2b204accd07a3185b58b1edc6e9b019472857a5d)
2023-05-17Daily bump.GCC Administrator
2023-05-16libstdc++: Fix src/c++17/memory_resource for H8 targets [PR107801]Jonathan Wakely
This fixes compilation failures for H8 multilibs. For the normal multilib (ILP16L32?), the chunk struct does not have the expected size, because uint32_t is type long and has alignment 4 (by default). This forces sizeof(chunk) to be 12 instead of the expected 10. We can fix that by using bitset::size_type instead of uint32_t, so that we only use a 16-bit size when size_t and pointers are 16-bit types. For the IL32P16 multilibs that use -mint32, int is wider than size_t and so arithmetic expressions involving size_t promote to int. This means we need some explicit casts back to size_t. libstdc++-v3/ChangeLog: PR libstdc++/107801 * src/c++17/memory_resource.cc (chunk::_M_bytes): Change type from uint32_t to bitset::size_type. Adjust static assertion. (__pool_resource::_Pool::replenish): Cast to size_t after multiplication instead of before. (__pool_resource::_M_alloc_pools): Ensure both arguments to std::max have type size_t. (cherry picked from commit 75e562d2c4303d3918be9d1563284b0c580c5e45)
2023-05-16libstdc++: Fix pool resource build errors for H8 [PR107801]Jonathan Wakely
The array of pool sizes was previously adjusted to work for msp430-elf which has 16-bit int and either 16-bit size_t or 20-bit size_t. The largest pool sizes were disabled unless size_t has more than 20 bits. The H8 family has 16-bit int but 32-bit size_t, which means that the largest sizes are enabled, but 1<<15 produces a negative number that then cannot be narrowed to size_t. Replace the test for 32-bit size_t with a test for 32-bit int, which means we won't use the 4kiB to 4MiB pools for targets with 16-bit int even if they have a wider size_t. libstdc++-v3/ChangeLog: PR libstdc++/107801 * src/c++17/memory_resource.cc (pool_sizes): Disable large pools for targets with 16-bit int. (cherry picked from commit 0f9659e770304d3c44cfa0e793833a461bc487aa)
2023-05-16libstdc++: Fix std::is_nothrow_invocable_r for uncopyable prvalues [PR91456]Jonathan Wakely
This is the last missing piece of PR 91456. This also removes the only use of the C++11 version of std::is_nothrow_invocable. libstdc++-v3/ChangeLog: PR libstdc++/91456 * include/std/type_traits (__is_nothrow_invocable): Remove. (__is_invocable_impl::__nothrow_type): New member type which checks if the conversion can throw. (__is_nt_invocable_impl): Replace class template with alias template to __is_nt_invocable_impl::__nothrow_type. * testsuite/20_util/is_nothrow_invocable/91456.cc: New test. * testsuite/20_util/is_nothrow_convertible/value.cc: Remove macro used by value_ext.cc test. * testsuite/20_util/is_nothrow_convertible/value_ext.cc: Remove test for non-standard __is_nothrow_invocable trait. (cherry picked from commit 71c828f84572d933979468baf2cf744180258ee4)
2023-05-16libstdc++: Add always_inline attribute to std::byte operatorsJonathan Wakely
libstdc++-v3/ChangeLog: * include/c_global/cstddef (byte): Add always_inline attribute to all operator overloads. (to_integer): Add always_inline attribute. (cherry picked from commit 4977507e329ee3ed410fc7338b9aaada81b68361)
2023-05-16libstdc++: Add nodiscard attribute to filesystem operationsJonathan Wakely
Some of these are not truly "pure" because they access the file system, e.g. exists and file_size, but they do not modify anything and are only useful for the return value. If you really want to use one of those functions just to check whether an error is reported (either via an exception or an error_code& argument) you can still do so, but you need to cast the discarded result to void. Several tests need such a change, because they were indeed only calling the functions to check for expected errors. libstdc++-v3/ChangeLog: * include/bits/fs_ops.h: Add nodiscard to all pure functions. * include/experimental/bits/fs_ops.h: Likewise. * testsuite/27_io/filesystem/operations/all.cc: Do not discard results of absolute and canonical. * testsuite/27_io/filesystem/operations/absolute.cc: Cast discarded result to void. * testsuite/27_io/filesystem/operations/canonical.cc: Likewise. * testsuite/27_io/filesystem/operations/exists.cc: Likewise. * testsuite/27_io/filesystem/operations/is_empty.cc: Likewise. * testsuite/27_io/filesystem/operations/read_symlink.cc: Likewise. * testsuite/27_io/filesystem/operations/status.cc: Likewise. * testsuite/27_io/filesystem/operations/symlink_status.cc: Likewise. * testsuite/27_io/filesystem/operations/temp_directory_path.cc: Likewise. * testsuite/experimental/filesystem/operations/canonical.cc: Likewise. * testsuite/experimental/filesystem/operations/exists.cc: Likewise. * testsuite/experimental/filesystem/operations/is_empty.cc: Likewise. * testsuite/experimental/filesystem/operations/read_symlink.cc: Likewise. * testsuite/experimental/filesystem/operations/temp_directory_path.cc: Likewise. (cherry picked from commit f7a148304a71f3d3ad6845b7966fdc3af88c9e45)
2023-05-16libstdc++: Use emplace in std::variant::operator=(T&&) as per LWG 3585Jonathan Wakely
This was approved at the October 2021 plenary. libstdc++-v3/ChangeLog: * include/std/variant (variant::operator=): Implement resolution of LWG 3585. * testsuite/20_util/variant/lwg3585.cc: New test. (cherry picked from commit 1395415fdc2d60e5346dbcf476749daf42d5b724)
2023-05-16libstdc++: Fix tests with non-const operator==Jonathan Wakely
These tests fail in strict -std=c++20 mode but their equality ops don't need to be non-const, it looks like an accident. This fixes two FAILs with -std=c++20: FAIL: 20_util/tuple/swap.cc (test for excess errors) FAIL: 26_numerics/valarray/87641.cc (test for excess errors) libstdc++-v3/ChangeLog: * testsuite/20_util/tuple/swap.cc (MoveOnly::operator==): Add const qualifier. * testsuite/26_numerics/valarray/87641.cc (X::operator==): Likewise. (cherry picked from commit fbad7a74aaaddea3d7b39045a09dd3860603658e)
2023-05-16libstdc++: Fix reading UTF-8 characters for 16-bit targets [PR104875]Jonathan Wakely
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. (cherry picked from commit 8f7b7c1495f92c72da154d32317943a2cc276ca8)
2023-05-16libstdc++: Add missing move in ranges::copyJonathan Wakely
This is needed to support a move-only output iterator when the input iterators are specializations of __normal_iterator. libstdc++-v3/ChangeLog: * include/bits/ranges_algobase.h (__detail::__copy_or_move): Move output iterator. * testsuite/25_algorithms/copy/constrained.cc: Check copying to move-only output iterator. (cherry picked from commit 2ff0e62275b1c322a8b65f38f8336f37d31c30e4)
2023-05-16libstdc++: Fix self-move for std::weak_ptr [PR108118]Jonathan Wakely
I think an alternative fix would be something like: _M_ptr = std::exchange(rhs._M_ptr, nullptr); _M_refcount = std::move(rhs._M_refcount); The standard's move-and-swap implementation generates smaller code at all levels except -O0 and -Og, so it seems simplest to just do what the standard says. libstdc++-v3/ChangeLog: PR libstdc++/108118 * include/bits/shared_ptr_base.h (weak_ptr::operator=): Implement as move-and-swap exactly as specified in the standard. * testsuite/20_util/weak_ptr/cons/self_move.cc: New test. (cherry picked from commit 92eb0adc14a5f84acce7e5bc780b81b1544b24aa)
2023-05-16libstdc++: Fix std::chrono::hh_mm_ss with unsigned rep [PR108265]Jonathan Wakely
libstdc++-v3/ChangeLog: PR libstdc++/108265 * include/std/chrono (hh_mm_ss): Do not use chrono::abs if duration rep is unsigned. Remove incorrect noexcept-specifier. * testsuite/std/time/hh_mm_ss/1.cc: Check unsigned rep. Check floating-point representations. Check default construction. (cherry picked from commit e36e57b032b2d70eaa1294d5921e4fd8ce12a74d)
2023-05-13Daily bump.GCC Administrator
2023-05-12libstdc++: Fix __max_diff_type::operator>>= for negative valuesPatrick Palka
This patch fixes sign bit propagation when right-shifting a negative __max_diff_type value by more than one, a bug that our existing test coverage didn't expose until r14-159-g03cebd304955a6 fixed the front end's 'signed typedef-name' handling that the test relies on (which is a non-standard extension to the language grammar). libstdc++-v3/ChangeLog: * include/bits/max_size_type.h (__max_diff_type::operator>>=): Fix propagation of sign bit. * testsuite/std/ranges/iota/max_size_type.cc: Avoid using the non-standard 'signed typedef-name'. Add some compile-time tests for right-shifting a negative __max_diff_type value by more than one. (cherry picked from commit 83470a5cd4c3d233e1d55b5e5553e1b9c553bf28)
2023-05-04Daily bump.GCC Administrator
2023-05-03libstdc++: Fix broken backport for std::lcm [PR105844]Jonathan Wakely
The backport for gcc-11 was incomplete and should have replaced all uses of std::__is_constant_evaluated with __builtin_is_constant_evaluated. We also need to prune some additional output for the new tests, because the r12-4425-g1595fe44e11a96 change to always prune those lines is not present on the branch. libstdc++-v3/ChangeLog: PR libstdc++/105844 * include/experimental/numeric (lcm): Use built-in instead of __is_constant_evaluated. * include/std/numeric (__abs_r, lcm): Likewise. * testsuite/26_numerics/gcd/105844.cc: Add dg-prune-output. * testsuite/26_numerics/lcm/105844.cc: Likewise.
2023-05-03libstdc++: Make std::lcm and std::gcd detect overflow [PR105844]Jonathan Wakely
When I fixed PR libstdc++/92978 I introduced a regression whereby std::lcm(INT_MIN, 1) and std::lcm(50000, 49999) would no longer produce errors during constant evaluation. Those calls are undefined, because they violate the preconditions that |m| and the result can be represented in the return type (which is int in both those cases). The regression occurred because __absu<unsigned>(INT_MIN) is well-formed, due to the explicit casts to unsigned in that new helper function, and the out-of-range multiplication is well-formed, because unsigned arithmetic wraps instead of overflowing. To fix 92978 I made std::gcm and std::lcm calculate |m| and |n| immediately, yielding a common unsigned type that was used to calculate the result. That was partly correct, but there's no need to use an unsigned type. Doing so only suppresses the overflow errors so the compiler can't detect them. This change replaces __absu with __abs_r that returns the common type (not its corresponding unsigned type). This way we can detect overflow in __abs_r when required, while still supporting the most-negative value when it can be represented in the result type. To detect LCM results that are out of range of the result type we still need explicit checks, because neither constant evaluation nor UBsan will complain about unsigned wrapping for cases such as std::lcm(500000u, 499999u). We can detect those overflows efficiently by using __builtin_mul_overflow and asserting. libstdc++-v3/ChangeLog: PR libstdc++/105844 * include/experimental/numeric (experimental::gcd): Simplify assertions. Use __abs_r instead of __absu. (experimental::lcm): Likewise. Remove use of __detail::__lcm so overflow can be detected. * include/std/numeric (__detail::__absu): Rename to __abs_r and change to allow signed result type, so overflow can be detected. (__detail::__lcm): Remove. (gcd): Simplify assertions. Use __abs_r instead of __absu. (lcm): Likewise. Remove use of __detail::__lcm so overflow can be detected. * testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines. * testsuite/26_numerics/lcm/lcm_neg.cc: Likewise. * testsuite/26_numerics/gcd/105844.cc: New test. * testsuite/26_numerics/lcm/105844.cc: New test. (cherry picked from commit 671970a5621e18e7079b4ca113e56434c858db66)
2023-05-03libstdc++: Strip absolute paths from files shown in Doxygen docsJonathan Wakely
This avoids showing absolute paths from the expansion of @srcdir@/libsupc++/ in the doxygen File List view. libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (STRIP_FROM_PATH): Remove prefixes from header paths. (cherry picked from commit 975e8e836ead0e9055a125a2a23463db5d847cb3)
2023-04-28Daily bump.GCC Administrator
2023-04-27libstdc++: Document LWG 1203 API change in manualJonathan Wakely
libstdc++-v3/ChangeLog: * doc/xml/manual/intro.xml: Document LWG 1203. * doc/html/*: Regenerate. (cherry picked from commit 8b1bc3051bd68ce193a8612fa3b1a65c0353b5b0)
2023-04-27libstdc++: Add missing runtime exception to licence noticeJonathan Wakely
This file is missing the GCC Runtime Library Exception text in the licence header. That is unintentional, and it should have been present. libstdc++-v3/ChangeLog: * include/std/barrier: Add missing runtime exception. (cherry picked from commit d7f282c4243e24f567b11a5cb6048a27a3df733d)
2023-04-27libstdc++: Fix printing of std::span for versioned namespaceFrançois Dumont
libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdSpanPrinter.__init__): Strip typename from version namespace. (cherry picked from commit ace4b7f295f407b16cfbc2e359f4ef7cd61d4a46)
2023-04-27libstdc++: Add pretty printer for std::initializer_listPhilipp Fent
Re-using the std::span printer, this now shows the contents of the initializer list instead of the pointer and length members. Signed-off-by: Philipp Fent <fent@in.tum.de> libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdSpanPrinter._iterator): Rename as iterator. (StdInitializerListPrinter): Define new printer. (build_libstdcxx_dictionary): Register new printer. * testsuite/libstdc++-prettyprinters/cxx11.cc: Check printer for initializer_list. (cherry picked from commit 71999fde2a454d1fa149e63825d8edbe0748c911)
2023-04-27libstdc++: Add pretty printer for std::spanPhilipp Fent
This improves the debug output for C++20 spans. Before: {static extent = 18446744073709551615, _M_ptr = 0x7fffffffb9a8, _M_extent = {_M_extent_value = 2}} Now with StdSpanPrinter: std::span of length 2 = {1, 2} Signed-off-by: Philipp Fent <fent@in.tum.de> libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdSpanPrinter): Define. * testsuite/libstdc++-prettyprinters/cxx20.cc: Test it. (cherry picked from commit fdb3f82fb324c3ddd7464d11c8ea60a98f486a0e)
2023-04-27libstdc++: Fix error in doxygen comments in <atomic>Jonathan Wakely
libstdc++-v3/ChangeLog: * include/std/atomic: Add missing @endcond doxygen comment.
2023-04-27libstdc++: Fix outdated docs about demangling exception messagesJonathan Wakely
The string returned by std::bad_exception::what() hasn't been a mangled name since PR libstdc++/14493 was fixed for GCC 4.2.0, so remove the docs showing how to demangle it. libstdc++-v3/ChangeLog: * doc/xml/manual/extensions.xml: Remove std::bad_exception from example program. * doc/html/manual/ext_demangling.html: Regenerate. (cherry picked from commit 688d126b69215db29774c249b052e52d765782b3)
2023-04-27libstdc++: Reduce Doxygen output for PDFJonathan Wakely
Including the header source code in the doxygen-generated PDF file makes it too large, and causes pdflatex to run out of memory. If we only set SOURCE_BROWSER=YES for the HTML docs then we won't include the sources in the PDF file. There are several macros defined for std::valarray that are only used to generate repetitive code and then #undef'd. Those aren't useful in the doxygen docs, especially the ones that reuse the same name in different files. Omitting them avoids warnings about duplicate labels in the refman.tex file. libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (SOURCE_BROWSER): Only set to YES for HTML docs. * include/bits/gslice_array.h (_DEFINE_VALARRAY_OPERATOR): Omit from doxygen docs. * include/bits/indirect_array.h (_DEFINE_VALARRAY_OPERATOR): Likewise. * include/bits/mask_array.h (_DEFINE_VALARRAY_OPERATOR): Likewise. * include/bits/slice_array.h (_DEFINE_VALARRAY_OPERATOR): Likewise. * include/std/valarray (_DEFINE_VALARRAY_UNARY_OPERATOR) (_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT) (_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT) (_DEFINE_BINARY_OPERATOR): Likewise. (cherry picked from commit afa69618d1627435841c9164b019ef98000e0365)
2023-04-27libstdc++: Fix dangling reference in filesystem::path::filename()Jonathan Wakely
The new -Wdangling-reference warning noticed this. libstdc++-v3/ChangeLog: * include/bits/fs_path.h (path::filename()): Fix dangling reference. (cherry picked from commit 49237fe6ef677a81eae701f937546210c90b5914)
2023-04-27libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064]Jonathan Wakely
libstdc++-v3/ChangeLog: PR libstdc++/109064 * python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker): Remove self-recursion in __init__. Add missing _supports. * testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count() and unique().
2023-04-27libstdc++: Fix uses_allocator_construction_args for pair<T&&, U&&> [PR108952]Jonathan Wakely
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. (cherry picked from commit 8e342c04550466ab088c33746091ce7f3498ee44)
2023-04-27libstdc++: Fix name of <experimental/optional> in commentJonathan Wakely
libstdc++-v3/ChangeLog: * include/experimental/optional: Fix header name in comment. (cherry picked from commit 38f321793ae18d25399f0396ac1371caa7cc7043)
2023-03-22Daily bump.GCC Administrator