aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
AgeCommit message (Collapse)AuthorFilesLines
3 dayslibstdc++: Fix memory_resource.cc bootstrap failure for non-gthreads targetsJonathan Wakely1-27/+39
The new choose_block_size function added in r16-2112-gac2fb60a67d6d1 was defined inside an #ifdef _GLIBCXX_HAS_GTHREADS group, which means that it's not available for single-threaded targets, and so can't be used by unsynchronized_pool_resource. Move it before that preprocessor group so it's always defined. libstdc++-v3/ChangeLog: * src/c++17/memory_resource.cc: Adjust indentation of unnamed namespaces. (pool_sizes): Add comment. (choose_block_size): Move outside preprocessor group for gthreads targets. * testsuite/20_util/synchronized_pool_resource/118681.cc: Require gthreads.
3 dayslibstdc++: Ensure pool resources meet alignment requirements [PR118681]Jonathan Wakely1-4/+22
For allocations with size > alignment and size % alignment != 0 we were sometimes returning pointers that did not meet the requested aligment. For example, allocate(24, 16) would select the pool for 24-byte objects and the second allocation from that pool (at offset 24 bytes into the pool) is only 8-byte aligned not 16-byte aligned. The pool resources need to round up the requested allocation size to a multiple of the alignment, so that the selected pool will always return allocations that meet the alignment requirement. libstdc++-v3/ChangeLog: PR libstdc++/118681 * src/c++17/memory_resource.cc (choose_block_size): New function. (synchronized_pool_resource::do_allocate): Use choose_block_size to determine appropriate block size. (synchronized_pool_resource::do_deallocate): Likewise (unsynchronized_pool_resource::do_allocate): Likewise. (unsynchronized_pool_resource::do_deallocate): Likewise * testsuite/20_util/synchronized_pool_resource/118681.cc: New test. * testsuite/20_util/unsynchronized_pool_resource/118681.cc: New test. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 dayslibstdc++: Implement mdspan and tests [PR107761].Luc Grosheintz1-1/+2
Implements the class mdspan as described in N4950, i.e. without P3029. It also adds tests for mdspan. This commit completes the implementation of P0009, i.e. the C++23 part <mdspan>. PR libstdc++/107761 libstdc++-v3/ChangeLog: * include/std/mdspan (mdspan): New class. * src/c++23/std.cc.in (mdspan): Add. * testsuite/23_containers/mdspan/class_mandate_neg.cc: New test. * testsuite/23_containers/mdspan/mdspan.cc: New test. * testsuite/23_containers/mdspan/layout_like.h: Add class LayoutLike which models a user-defined layout. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
4 dayslibstdc++: Make debug iterator pointer sequence const [PR116369]François Dumont1-40/+134
In revision a35dd276cbf6236e08bcf6e56e62c2be41cf6e3c the debug sequence have been made mutable to allow attach iterators to const containers. This change completes this fix by also declaring debug unordered container members mutable. Additionally the debug iterator sequence is now a pointer-to-const and so _Safe_sequence_base _M_attach and all other methods are const qualified. Not-const methods exported are preserved for abi backward compatibility. libstdc++-v3/ChangeLog: PR c++/116369 * config/abi/pre/gnu-versioned-namespace.ver: Use new const qualified symbols. * config/abi/pre/gnu.ver: Add new const qualified symbols. * include/debug/safe_base.h (_Safe_iterator_base::_M_sequence): Declare as pointer-to-const. (_Safe_iterator_base::_M_attach, _M_attach_single): New, take pointer-to-const _Safe_sequence_base. (_Safe_sequence_base::_M_detach_all, _M_detach_singular, _M_revalidate_singular) (_M_swap, _M_get_mutex): New, const qualified. (_Safe_sequence_base::_M_attach, _M_attach_single, _M_detach, _M_detach_single): const qualify. * include/debug/safe_container.h (_Safe_container<>::_M_cont): Add const qualifier. (_Safe_container<>::_M_swap_base): New. (_Safe_container(_Safe_container&&, const _Alloc&, std::false_type)): Adapt to use latter. (_Safe_container<>::operator=(_Safe_container&&)): Likewise. (_Safe_container<>::_M_swap): Likewise and take parameter as const reference. * include/debug/safe_unordered_base.h (_Safe_local_iterator_base::_M_safe_container): New. (_Safe_local_iterator_base::_Safe_local_iterator_base): Take _Safe_unordered_container_base as pointer-to-const. (_Safe_unordered_container_base::_M_attach, _M_attach_single): New, take container as _Safe_unordered_container_base pointer-to-const. (_Safe_unordered_container_base::_M_local_iterators, _M_const_local_iterators): Add mutable. (_Safe_unordered_container_base::_M_detach_all, _M_swap): New, const qualify. (_Safe_unordered_container_base::_M_attach_local, _M_attach_local_single) (_M_detach_local, _M_detach_local_single): Add const qualifier. * include/debug/safe_unordered_container.h (_Safe_unordered_container::_M_self()): New. * include/debug/safe_unordered_container.tcc (_Safe_unordered_container::_M_invalidate_if, _M_invalidated_local_if): Use latter. * include/debug/safe_iterator.h (_Safe_iterator<>::_M_attach, _M_attach_single): Take _Safe_sequence_base as pointer-to-const. (_Safe_iterator<>::_M_get_sequence): Add const_cast and comment about it. * include/debug/safe_local_iterator.h (_Safe_local_iterator<>): Replace usages of _M_sequence member by _M_safe_container(). (_Safe_local_iterator<>::_M_attach, _M_attach_single): Take _Safe_unordered_container_base as pointer-to-const. (_Safe_local_iterator<>::_M_get_sequence): Rename into... (_Safe_local_iterator<>::_M_get_ucontainer): ...this. Add necessary const_cast and comment to explain it. (_Safe_local_iterator<>::_M_is_begin, _M_is_end): Adapt. * include/debug/safe_local_iterator.tcc: Adapt. * include/debug/safe_sequence.h (_Safe_sequence<>::_M_invalidate_if, _M_transfer_from_if): Add const qualifier. * include/debug/safe_sequence.tcc: Adapt. * include/debug/deque (std::__debug::deque::erase): Adapt to use new const qualified methods. * include/debug/formatter.h: Adapt. * include/debug/forward_list (_Safe_forward_list::_M_this): Add const qualification and return pointer for consistency with 'this' keyword. (_Safe_forward_list::_M_swap_aux): Rename into... (_Safe_forward_list::_S_swap_aux): ...this and take sequence as const reference. (forward_list<>::resize): Adapt to use const methods. * include/debug/list (list<>::resize): Likewise. * src/c++11/debug.cc: Adapt to const qualification. * testsuite/util/testsuite_containers.h (forward_members_unordered::forward_members_unordered): Add check on local_iterator conversion to const_local_iterator. (forward_members::forward_members): Add check on iterator conversion to const_iterator. * testsuite/23_containers/unordered_map/const_container.cc: New test case. * testsuite/23_containers/unordered_multimap/const_container.cc: New test case. * testsuite/23_containers/unordered_multiset/const_container.cc: New test case. * testsuite/23_containers/unordered_set/const_container.cc: New test case. * testsuite/23_containers/vector/debug/mutex_association.cc: Adapt.
5 dayslibstdc++: Implement ranges::shift_left/right from P2440R1Patrick Palka1-2/+6
The implementation is just a copy of std::shift_left/right with the following changes: - check bidirectional_iterator instead of iterator_category - cope with __last being a distinct sentinel type - for shift_left, return the subrange {__first, X} instead of X - for shift_right, return the subrange {X, ranges::next(__first, __last)} instead of X - use the ranges:: versions of move_backward, move and iter_swap - don't bother std::move'ing any iterators, it's unnecessary since all iterators are forward, it's visually noisy, and in earlier versions of this patch it introduced subtle use-after-move bugs In passing also use the __glibcxx_shift macro to guard the std::shift_left/right implementations. libstdc++-v3/ChangeLog: * include/bits/ranges_algo.h (shift_left, shift_right): Guard with __glibcxx_shift >= 201806L. (ranges::__shift_left_fn, ranges::shift_left): Define for C++23. (ranges::__shift_right_fn, ranges::shift_right): Likewise. * include/bits/version.def (shift): Update for C++23. * include/bits/version.h: Regenerate. * src/c++23/std.cc.in: Add ranges::shift_left/right. * testsuite/25_algorithms/shift_left/constrained.cc: New test, based off of 1.cc. * testsuite/25_algorithms/shift_right/constrained.cc: New test, based off of 1.cc. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
10 dayslibstdc++: Use hidden friends for __normal_iterator operatorsJonathan Wakely2-20/+0
As suggested by Jason, this makes all __normal_iterator operators into friends so they can be found by ADL and don't need to be separately exported in module std. The operator<=> comparing two iterators of the same type is removed entirely, instead of being made a hidden friend. That overload was added by r12-5882-g2c7fb16b5283cf to deal with unconstrained operator overloads found by ADL, as defined in the testsuite_greedy_ops.h header. We don't actually test that case as there's no unconstrained <=> in that header, and it doesn't seem reasonable for anybody to define such an operator<=> in C++20 when they should constrain their overloads properly (e.g. using a requires-clause). The homogeneous operator<=> overloads added for reverse_iterator and move_iterator could also be removed, but that's not part of this commit. I also had to reorder the __attribute__((always_inline)) and [[nodiscard]] attributes on the pre-c++20 operators, because Clang won't allow [[foo]] after __attribute__((bar)) on a friend function: <source>:4:36: error: an attribute list cannot appear here 4 | __attribute__((always_inline)) [[nodiscard]] friend bool | ^~~~~~~~~~~~~ libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (__normal_iterator): Make all non-member operators hidden friends, except ... (operator<=>(__normal_iterator<I,C>, __normal_iterator<I,C>)): Remove. * src/c++11/string-inst.cc: Remove explicit instantiations of operators that are no longer templates. * src/c++23/std.cc.in (__gnu_cxx): Do not export operators for __normal_iterator. Reviewed-by: Patrick Palka <ppalka@redhat.com>
11 dayslibstdc++: Implement default_accessor from mdspan.Luc Grosheintz1-1/+2
libstdc++-v3/ChangeLog: * include/std/mdspan (default_accessor): New class. * src/c++23/std.cc.in: Register default_accessor. * testsuite/23_containers/mdspan/accessors/default.cc: New test. * testsuite/23_containers/mdspan/accessors/default_neg.cc: New test. Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2025-06-26libstdc++: Implement C++26 P2927R3 - Inspecting exception_ptrJakub Jelinek1-0/+3
The following patch attempts to implement the C++26 P2927R3 - Inspecting exception_ptr paper (but not including P3748R0, I plan to play with it incrementally and it will really depend on the Constexpr exceptions patch). The function template is implemented using an out of line private method of exception_ptr, so that P3748R0 then can use if consteval and provide a constant evaluation variant of it. 2025-06-26 Jakub Jelinek <jakub@redhat.com> * include/bits/version.def (exception_ptr_cast): Add. * include/bits/version.h: Regenerate. * libsupc++/exception: Define __glibcxx_want_exception_ptr_cast before including bits/version.h. * libsupc++/exception_ptr.h (std::exception_ptr_cast): Define. (std::__exception_ptr::exception_ptr::_M_exception_ptr_cast): Declare. * libsupc++/eh_ptr.cc (std::__exception_ptr::exception_ptr::_M_exception_ptr_cast): Define. * src/c++23/std.cc.in (std::exception_ptr_cast): Export. * config/abi/pre/gnu.ver: Export _ZNKSt15__exception_ptr13exception_ptr21_M_exception_ptr_castERKSt9type_info at CXXABI_1.3.17. * testsuite/util/testsuite_abi.cc (check_version): Allow CXXABI_1.3.17. * testsuite/18_support/exception_ptr/exception_ptr_cast.cc: New test.
2025-06-26c++, libstdc++: Implement C++26 P2830R10 - Constexpr Type OrderingJakub Jelinek1-0/+4
The following patch attempts to implement the C++26 P2830R10 - Constexpr Type Ordering paper, with a minor change that std::type_order<T, U> class template doesn't derive from integer_constant, because std::strong_ordering is not a structural type (except in MSVC), so instead it is just a class template with static constexpr strong_ordering value member and also value_type, type and 2 operators. The paper mostly talks about using something other than mangled names for the ordering, but given that the mangler is part of the GCC C++ FE, using the mangler seems to be the best ordering choice to me. 2025-06-26 Jakub Jelinek <jakub@redhat.com> gcc/cp/ * cp-trait.def: Implement C++26 P2830R10 - Constexpr Type Ordering. (TYPE_ORDER): New. * method.cc (type_order_value): Define. * cp-tree.h (type_order_value): Declare. * semantics.cc (trait_expr_value): Use gcc_unreachable also for CPTK_TYPE_ORDER, adjust comment. (finish_trait_expr): Handle CPTK_TYPE_ORDER. * constraint.cc (diagnose_trait_expr): Likewise. gcc/testsuite/ * g++.dg/cpp26/type-order1.C: New test. * g++.dg/cpp26/type-order2.C: New test. * g++.dg/cpp26/type-order3.C: New test. libstdc++-v3/ * include/bits/version.def (type_order): New. * include/bits/version.h: Regenerate. * libsupc++/compare: Define __glibcxx_want_type_order before including bits/version.h. (std::type_order, std::type_order_v): New trait and template variable. * src/c++23/std.cc.in (std::type_order, std::type_order_v): Export. * testsuite/18_support/comparisons/type_order/1.cc: New test.
2025-06-12libstdc++: Implement layout_stride from mdspan.Luc Grosheintz1-1/+2
Implements the remaining parts of layout_left and layout_right; and all of layout_stride. The implementation of layout_stride::mapping::is_exhaustive applies the following change to the standard: 4266. layout_stride::mapping should treat empty mappings as exhaustive https://cplusplus.github.io/LWG/issue4266 The preconditions for layout_stride(extents, strides) are not checked. libstdc++-v3/ChangeLog: * include/std/mdspan (layout_stride): New class. * src/c++23/std.cc.in: Add layout_stride. Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com> Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-06-12libstdc++: Implement layout_right from mdspan.Luc Grosheintz1-0/+1
Implement the parts of layout_left that depend on layout_right; and the parts of layout_right that don't depend on layout_stride. libstdc++-v3/ChangeLog: * include/std/mdspan (layout_right): New class. * src/c++23/std.cc.in: Add layout_right. Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com> Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-06-12libstdc++: Implement layout_left from mdspan.Luc Grosheintz1-0/+1
Implements the parts of layout_left that don't depend on any of the other layouts. libstdc++-v3/ChangeLog: * include/std/mdspan (layout_left): New class. * src/c++23/std.cc.in: Add layout_left. Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com> Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-06-05libstdc++: Export std::indirect and std::polymorphic from std module [PR119152]Tomasz Kamiński1-0/+8
PR libstdc++/119152 libstdc++-v3/ChangeLog: * src/c++23/std.cc.in (std::indirect, pmr::indirect) [__cpp_lib_indirect] (std::polymorphic, pmr::polymorphic) [__cpp_lib_polymorphic]: Export.
2025-06-04libstdc++: Implement C++23 P1659R3 starts_with and ends_withPatrick Palka1-0/+4
This implements ranges::starts_with and ranges::ends_with from the C++23 paper P1659R3. The corresponding_S_impl member functions take optional optional size parameters __n1 and __n2 of the two ranges, where -1 means the corresponding size is not known. libstdc++-v3/ChangeLog: * include/bits/ranges_algo.h (__starts_with_fn, starts_with): Define. (__ends_with_fn, ends_with): Define. * include/bits/version.def (ranges_starts_ends_with): Define. * include/bits/version.h: Regenerate. * include/std/algorithm: Provide __cpp_lib_ranges_starts_ends_with. * src/c++23/std.cc.in (ranges::starts_with): Export. (ranges::ends_with): Export. * testsuite/25_algorithms/ends_with/1.cc: New test. * testsuite/25_algorithms/starts_with/1.cc: New test. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2025-06-03libstdc++: Fix errors and incorrect returns in atomic timed waitsJonathan Wakely1-9/+15
The __detail::__wait_until function has a comment that should have been removed when r16-1000-g225622398a9631 changed the return type from a std::pair to a struct with three members. The __atomic_wait_address_until_v and __atomic_wait_address_for_v function templates are apparently never used or instantiated, because they don't compile. This fixes them, but they're still unused. I plan to make use of them in a later commit. In __atomic_wait_address_until_v, __res.first in the return statement should have also been changed when r16-1000-g225622398a9631 changed __wait_result_type, and &__args should have been changed to just __args by r16-988-g219bb905a60d95. In __atomic_wait_address_for_v, the parameter is a copy & paste error and should use chrono::duration not chrono::time_point Fix _M_spin_until_impl so that the _M_has_val member of the result is accurate. If the deadline has passed then it never enters the loop and so never loads a fresh value, so _M_has_val should be false. There's also a redundant clock::now() call in __spin_until_impl which can be removed, we can reuse the call immediately before it. libstdc++-v3/ChangeLog: * include/bits/atomic_timed_wait.h (__detail::__wait_until): Remove incorrect comment. (__atomic_wait_address_until_v): Do not take address of __args in call to __detail::__wait_until. Fix return statement to refer to member of __wait_result_type. (__atomic_wait_address_for_v): Change parameter type from time_point to duration. * src/c++20/atomic.cc (__spin_until_impl): Fix incorrect return value. Reuse result of first call to clock.
2025-06-03libstdc++: Remove redundant macro checks in std.cc.inJonathan Wakely1-8/+0
__cpp_lib_any and __cpp_lib_chrono are defined unconditionally in C++20 and __cpp_lib_three_way_comparison and __cpp_lib_concepts depend on front-end features which are definitely supported by GCC trunk and all non-GCC compilers we care about. libstdc++-v3/ChangeLog: * src/c++23/std.cc.in: Remove redundant checks for feature test macros that are always true. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-05-30libstdc++: Define __wait_result_type for atomic waitingJonathan Wakely1-19/+36
libstdc++-v3/ChangeLog: * include/bits/atomic_timed_wait.h: Use __wait_result_type. * include/bits/atomic_wait.h (__wait_result_type): New struct. (__wait_args::_M_prep_for_wait_on): Rename to _M_setup_wait, use __wait_result_type. (__atomic_wait_address): Adjust to call _M_setup_wait. * src/c++20/atomic.cc (__spin_impl): Use __wait_result_type. (__wait_impl): Likewise. (__spin_until_impl): Likewise. (__wait_until_impl): Likewise.
2025-05-30libstdc++: Move atomic wait/notify entry points into the libraryJonathan Wakely3-3/+471
This moves the implementation details of atomic wait/notify functions into the library, so that only a small API surface is exposed to users. This also fixes some race conditions present in the design for proxied waits: - The stores to _M_ver in __notify_impl must be protected by the mutex, and the loads from _M_ver in __wait_impl and __wait_until_impl to check for changes must also be protected by the mutex. This ensures that checking _M_ver for updates and waiting on the condition_variable happens atomically. Otherwise it's possible to have: _M_ver == old happens-before {++_M_ver; cv.notify;} which happens-before cv.wait. That scenario results in a missed notification, and so the waiting function never wakes. This wasn't a problem for Linux, because the futex wait call re-checks the _M_ver value before sleeping, so the increment cannot interleave between the check and the wait. - The initial load from _M_ver that reads the 'old' value used for the _M_ver == old checks must be done before loading and checking the value of the atomic variable. Otherwise it's possible to have: var.load() == val happens-before {++_M_ver; _M_cv.notify_all();} happens-before {old = _M_ver; lock mutex; if (_M_ver == old) cv.wait}. This results in the waiting thread seeing the already-incremented value of _M_ver and then waiting for it to change again, which doesn't happen. This race was present even for Linux, because using a futex instead of mutex+condvar doesn't prevent the increment from happening before the waiting threads checks for the increment. The first race can be solved locally in the waiting and notifying functions, by acquiring the mutex lock earlier in the function. The second race cannot be fixed locally, because the load of the atomic variable and the check for updates to _M_ver happen in different functions (one in a function template in the headers and one in the library). We do have an _M_old data member in the __wait_args_base struct which was previously only used for non-proxy waits using a futex. We can add a new entry point into the library to look up the waitable state for the address and then load its _M_ver into the _M_old member. This allows the inline function template to ensure that loading _M_ver happens-before testing whether the atomic variable has been changed, so that we can reliably tell if _M_ver changes after we've already tested the atomic variable. This isn't 100% reliable, because _M_ver could be incremented 2^32 times and wrap back to the same value, but that seems unlikely in practice. If/when we support waiting on user-defined predicates (which could execute long enough for _M_ver to wrap) we might want to always wait with a timeout, so that we get a chance to re-check the predicate even in the rare case that _M_ver wraps. Another change is to make the __wait_until_impl function take a __wait_clock_t::duration instead of a __wait_clock_t::time_point, so that the __wait_until_impl function doesn't depend on the symbol name of chrono::steady_clock. Inside the library it can be converted back to a time_point for the clock. This would potentially allow using a different clock, if we made a different __abi_version in the __wait_args imply waiting with a different clock. This also adds a void* to the __wait_args_base structure, so that __wait_impl can store the __waitable_state* in there the first time it's looked up for a given wait, so that it doesn't need to be retrieved again on each loop. This requires passing the __wait_args_base structure by non-const reference. The __waitable_state::_S_track function can be removed now that it's all internal to the library, and namespace-scope RAII types added for locking and tracking contention. libstdc++-v3/ChangeLog: * config/abi/pre/gnu.ver: Add new symbol version and exports. * include/bits/atomic_timed_wait.h (__platform_wait_until): Move to atomic.cc. (__cond_wait_until, __spin_until_impl): Likewise. (__wait_until_impl): Likewise. Change __wait_args_base parameter to non-const reference and change third parameter to __wait_clock_t::duration. (__wait_until): Change __wait_args_base parameter to non-const reference. Change Call time_since_epoch() to get duration from time_point. (__wait_for): Change __wait_args_base parameter to non-const reference. (__atomic_wait_address_until): Call _M_prep_for_wait_on on args. (__atomic_wait_address_for): Likewise. (__atomic_wait_address_until_v): Qualify call to avoid ADL. Do not forward __vfn. * include/bits/atomic_wait.h (__platform_wait_uses_type): Use alignof(T) not alignof(T*). (__futex_wait_flags, __platform_wait, __platform_notify) (__waitable_state, __spin_impl, __notify_impl): Move to atomic.cc. (__wait_impl): Likewise. Change __wait_args_base parameter to non-const reference. (__wait_args_base::_M_wait_state): New data member. (__wait_args_base::_M_prep_for_wait_on): New member function. (__wait_args_base::_M_load_proxy_wait_val): New member function. (__wait_args_base::_S_memory_order_for): Remove member function. (__atomic_wait_address): Call _M_prep_for_wait_on on args. (__atomic_wait_address_v): Qualify call to avoid ADL. * src/c++20/Makefile.am: Add new file. * src/c++20/Makefile.in: Regenerate. * src/c++20/atomic.cc: New file. * testsuite/17_intro/headers/c++1998/49745.cc: Remove XFAIL for C++20 and later. * testsuite/29_atomics/atomic/wait_notify/100334.cc: Remove use of internal implementation details. * testsuite/util/testsuite_abi.cc: Add GLIBCXX_3.4.35 version.
2025-05-26libstdc++: Implement C++26 function_ref [PR119126]Tomasz Kamiński1-0/+7
This patch implements C++26 function_ref as specified in P0792R14, with correction for constraints for constructor accepting nontype_t parameter from LWG 4256. As function_ref may store a pointer to the const object, __Ptrs::_M_obj is changed to const void*, so again we do not cast away const from const objects. To help with necessary casts, a __polyfunc::__cast_to helper is added, that accepts reference to or target type direclty. The _Invoker now defines additional call methods used by function_ref: _S_ptrs() for invoking target passed by reference, and __S_nttp, _S_bind_ptr, _S_bind_ref for handling constructors accepting nontype_t. The existing _S_call_storage is changed to thin wrapper, that initialies _Ptrs, and forwards to _S_call_ptrs. This reduced the most uses of _Storage::_M_ptr and _Storage::_M_ref, so this functions was removed, and _Manager uses were adjusted. Finally we make function_ref available in freestanding mode, as move_only_function and copyable_function are currently only available in hosted, so we define _Manager and _Mo_base only if either __glibcxx_move_only_function or __glibcxx_copyable_function is defined. PR libstdc++/119126 libstdc++-v3/ChangeLog: * doc/doxygen/stdheader.cc: Added funcref_impl.h file. * include/Makefile.am: Added funcref_impl.h file. * include/Makefile.in: Added funcref_impl.h file. * include/bits/funcref_impl.h: New file. * include/bits/funcwrap.h: (_Ptrs::_M_obj): Const-qualify. (_Storage::_M_ptr, _Storage::_M_ref): Remove. (__polyfunc::__cast_to) Define. (_Base_invoker::_S_ptrs, _Base_invoker::_S_nttp) (_Base_invoker::_S_bind_ptrs, _Base_invoker::_S_bind_ref) (_Base_invoker::_S_call_ptrs): Define. (_Base_invoker::_S_call_storage): Foward to _S_call_ptrs. (_Manager::_S_local, _Manager::_S_ptr): Adjust for _M_obj being const qualified. (__polyfunc::_Manager, __polyfunc::_Mo_base): Guard with __glibcxx_move_only_function || __glibcxx_copyable_function. (__polyfunc::__skip_first_arg, __polyfunc::__deduce_funcref) (std::function_ref) [__glibcxx_function_ref]: Define. * include/bits/utility.h (std::nontype_t, std::nontype) (__is_nontype_v) [__glibcxx_function_ref]: Define. * include/bits/version.def: Define function_ref. * include/bits/version.h: Regenerate. * include/std/functional: Define __cpp_lib_function_ref. * src/c++23/std.cc.in (std::nontype_t, std::nontype) (std::function_ref) [__cpp_lib_function_ref]: Export. * testsuite/20_util/function_ref/assign.cc: New test. * testsuite/20_util/function_ref/call.cc: New test. * testsuite/20_util/function_ref/cons.cc: New test. * testsuite/20_util/function_ref/cons_neg.cc: New test. * testsuite/20_util/function_ref/conv.cc: New test. * testsuite/20_util/function_ref/deduction.cc: New test. * testsuite/20_util/function_ref/mutation.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-05-14libstdc++: Implement C++26 copyable_function [PR119125]Tomasz Kamiński1-0/+3
This patch implements C++26 copyable_function as specified in P2548R6. It also implements LWG 4255 that adjust move_only_function so constructing from empty copyable_function, produces empty functor. This falls from existing checks, after specializing __is_polymorphic_function_v for copyable_function specializations. For compatible invoker signatures, the move_only_function may be constructed from copyable_funciton without double indirection. To achieve that we derive _Cpy_base from _Mo_base, and specialize __is_polymorphic_function_v for copyable_function. Similary copyable_functions with compatible signatures can be converted without double indirection. As we starting to use _Op::_Copy operation from the _M_manage function, invocations of that functions may now throw exceptions, so noexcept needs to be removed from the signature of stored _M_manage pointers. This also affects operations in _Mo_base, however we already wrap _M_manage invocations in noexcept member functions (_M_move, _M_destroy, swap). PR libstdc++/119125 libstdc++-v3/ChangeLog: * doc/doxygen/stdheader.cc: Addded cpyfunc_impl.h header. * include/Makefile.am: Add bits cpyfunc_impl.h. * include/Makefile.in: Add bits cpyfunc_impl.h. * include/bits/cpyfunc_impl.h: New file. * include/bits/mofunc_impl.h: Mention LWG 4255. * include/bits/move_only_function.h: Update header description and change guard to also check __glibcxx_copyable_function. (_Manager::_Func): Remove noexcept. (std::__is_polymorphic_function_v<move_only_function<_Tp>>) (__variant::_Never_valueless_alt<std::move_only_function<_Signature...>>) (move_only_function) [__glibcxx_move_only_function]: Adjust guard. (std::__is_polymorphic_function_v<copyable_function<_Tp>>) (__variant::_Never_valueless_alt<std::copyable_function<_Signature...>>) (__polyfunc::_Cpy_base, std::copyable_function) [__glibcxx_copyable_function]: Define. * include/bits/version.def: Define copyable_function. * include/bits/version.h: Regenerate. * include/std/functional: Define __cpp_lib_copyable_function. * src/c++23/std.cc.in (copyable_function) [__cpp_lib_copyable_function]: Export. * testsuite/20_util/copyable_function/call.cc: New test based on move_only_function tests. * testsuite/20_util/copyable_function/cons.cc: New test based on move_only_function tests. * testsuite/20_util/copyable_function/conv.cc: New test based on move_only_function tests. * testsuite/20_util/copyable_function/copy.cc: New test. * testsuite/20_util/copyable_function/move.cc: New test based on move_only_function tests. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-05-10vxworks: libstdc++: include ioLib.h for dup()Alexandre Oliva1-0/+4
vxworks's dup function is not declared in unistd.h, but c++23/print.cc expects to be able to call it if unistd.h is available. On vxworks, the function is only declared in ioLib.h, so arrange to include it. for libstdc++-v3/ChangeLog * src/c++23/print.cc [__VXWORKS__]: Include ioLib.h.
2025-05-07libstdc++: Add missing export for std::is_layout_compatible_v [PR120159]Jonathan Wakely1-0/+1
libstdc++-v3/ChangeLog: PR libstdc++/120159 * src/c++23/std.cc.in (is_layout_compatible_v): Export.
2025-05-07libstdc++: Fix module std export for std::extentsJonathan Wakely1-0/+3
libstdc++-v3/ChangeLog: * src/c++23/std.cc.in: Fix export for std::extents.
2025-05-07libstdc++: Implement std::extents [PR107761].Luc Grosheintz1-1/+5
This implements std::extents from <mdspan> according to N4950 and contains partial progress towards PR107761. If an extent changes its type, there's a precondition in the standard, that the value is representable in the target integer type. This precondition is not checked at runtime. The precondition for 'extents::{static_,}extent' is that '__r < rank()'. For extents<T> this precondition is always violated and results in calling __builtin_trap. For all other specializations it's checked via __glibcxx_assert. PR libstdc++/107761 libstdc++-v3/ChangeLog: * include/std/mdspan (extents): New class. * src/c++23/std.cc.in: Add 'using std::extents'. Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2025-05-06libstdc++: Fix dangling pointer in fs::path::operator+=(*this) [PR120029]Jonathan Wakely1-0/+10
When concatenating a path we reallocate the left operand's storage to make room for the new components being added. When the two operands are the same object, or the right operand is one of the components of the left operand, the reallocation invalidates the pointers that refer into the right operand's storage. The solution in this commit is to detect these aliasing cases and just do the concatenation in terms of the contained string, as that code already handles the case where the string aliases the path. The standard specifies the concatenation in terms of the native() string, so all this change does is disable the optimized implementation of concatenation for path objects which attempts to avoid re-parsing the path from the concatenated string. The potential loss of performance for this case isn't likely to be an issue, because concatenating a path with itself (or one of its existing components) probably isn't a common use case. The Filesystem TS implementation doesn't have the optimized form of concatenation and always does it in terms of the native string and reparsing the whole thing, so doesn't have this bug. A test is added to confirm that anyway (that test has some slightly different results due to different behaviour for trailing slashes and implicit "." filenames in the TS spec). libstdc++-v3/ChangeLog: PR libstdc++/120029 * src/c++17/fs_path.cc (path::operator+=(const path&)): Handle parameters that alias the path or one of its components. * testsuite/27_io/filesystem/path/concat/120029.cc: New test. * testsuite/experimental/filesystem/path/concat/120029.cc: New test.
2025-05-02libstdc++: Add some more makefile dependenciesJonathan Wakely4-13/+35
Add more prerequisites for wchar and dual-abi targets in the src/c++11 directory, and simplify the existing ones (we don't need to add the main xxx.cc source file as a prerequisite of xxx.o because that's implicit, we only need to add the ones that Make can't determine on its own). Also add similar prerequisites for the dual-abi targets in the src/c++17 directory. libstdc++-v3/ChangeLog: * src/c++11/Makefile.am: Simplify existing prerequisites for wchar and dual-abi targets that are built from other sources. Add similar prerequisites for more wchar and dual-abi files. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.am [ENABLE_DUAL_ABI]: Add prerequisites for dual-abi targets that are built from other sources. * src/c++17/Makefile.in: Regenerate.
2025-04-25libstdc++: Add some makefile dependenciesJonathan Wakely2-0/+16
This ensures that wstring-inst.o and similar files will be rebuilt when string-inst.cc changes. libstdc++-v3/ChangeLog: * src/c++11/Makefile.am: Add prerequisites for targets that depend on string-inst.cc. * src/c++11/Makefile.in: Regenerate.
2025-04-25libstdc++: Define __cpp_lib_format_ranges in format header [PR109162]Tomasz Kamiński1-4/+2
As P2286R8 and P2585R1 as now fully implemented, we now define __cpp_lib_format_ranges feature test macro with __cpp_lib_format_ranges. This macro is provided only in <format>. Uses of internal __glibcxx_format_ranges are also updated. PR libstdc++/109162 libstdc++-v3/ChangeLog: * include/bits/version.def (format_ranges): Remove no_stdname and update value. * include/bits/version.h: Regenerate. * src/c++23/std.cc.in: Replace __glibcxx_format_ranges with __cpp_lib_format_ranges. * testsuite/std/format/formatter/lwg3944.cc: Likewise. * testsuite/std/format/parse_ctx.cc: Likewise. * testsuite/std/format/string.cc: Likewise. * testsuite/std/format/ranges/feature_test.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-23libstdc++: fix possible undefined atomic lock-free type aliases in module stdZENG Hao1-0/+4
When building for 'i386-*' targets, all basic types are 'sometimes lock-free' and thus std::atomic_signed_lock_free and std::atomic_unsigned_lock_free are not declared. In the header <atomic>, they are placed in preprocessor condition __cpp_lib_atomic_lock_free_type_aliases. In module std, they should be the same. libstdc++-v3/ChangeLog: * src/c++23/std.cc.in (atomic_signed_lock_free): Guard with preprocessor check for __cpp_lib_atomic_lock_free_type_aliases. (atomic_unsigned_lock_free): Likewise.
2025-04-15libstdc++: Implement formatter for ranges and range_formatter [PR109162]Tomasz Kamiński1-0/+6
This patch implements formatter specialization for input_ranges and range_formatter class from P2286R8, as adjusted by P2585R1. The formatter for pair/tuple is not yet provided, making maps not formattable. This introduces an new _M_format_range member to internal __formatter_str, that formats range as _CharT as string, according to the format spec. This function transform any contiguous range into basic_string_view directly, by computing size if necessary. Otherwise, for ranges for which size can be computed (forward_range or sized_range) we use a stack buffer, if they are sufficiently small. Finally, we create a basic_string<_CharT> from the range, and format its content. In case when padding is specified, this is handled by firstly formatting the content of the range to the temporary string object. However, this can be only implemented if the iterator of the basic_format_context is internal type-erased iterator used by implementation. Otherwise a new basic_format_context would need to be created, which would require rebinding of handles stored in the arguments: note that format spec for element type could retrieve any format argument from format context, visit and use handle to format it. As basic_format_context provide no user-facing constructor, the user are not able to construct object of that type with arbitrary iterators. The signatures of the user-facing parse and format methods of the provided formatters deviate from the standard by constraining types of params: * _CharT is constrained __formatter::__char * basic_format_parse_context<_CharT> for parse argument * basic_format_context<_Out, _CharT> for format second argument The standard specifies last three of above as unconstrained types. These types are later passed to possibly user-provided formatter specializations, that are required via formattable concept to only accept above types. Finally, the formatter<input_range, _CharT> specialization is implemented without using specialization of range-default-formatter exposition only template as base class, while providing same functionality. PR libstdc++/109162 libstdc++-v3/ChangeLog: * include/std/format (__format::__has_debug_format, _Pres_type::_Pres_seq) (_Pres_type::_Pres_str, __format::__Stackbuf_size): Define. (_Separators::_S_squares, _Separators::_S_parens, _Separators::_S_comma) (_Separators::_S_colon): Define additional constants. (_Spec::_M_parse_fill_and_align): Define overload accepting list of excluded characters for fill, and forward existing overload. (__formatter_str::_M_format_range): Define. (__format::_Buf_sink) Use __Stackbuf_size for size of array. (__format::__is_map_formattable, std::range_formatter) (std::formatter<_Rg, _CharT>): Define. * src/c++23/std.cc.in (std::format_kind, std::range_format) (std::range_formatter): Export. * testsuite/std/format/formatter/lwg3944.cc: Guarded tests with __glibcxx_format_ranges. * testsuite/std/format/formatter/requirements.cc: Adjusted for standard behavior. * testsuite/23_containers/vector/bool/format.cc: Test vector<bool> formatting. * testsuite/std/format/ranges/format_kind.cc: New test. * testsuite/std/format/ranges/formatter.cc: New test. * testsuite/std/format/ranges/sequence.cc: New test. * testsuite/std/format/ranges/string.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-11libstdc++: Add fast_float patch to LOCAL_PATCHESJonathan Wakely1-0/+1
libstdc++-v3/ChangeLog: * src/c++17/fast_float/LOCAL_PATCHES: Update.
2025-04-11libstdc++: Support aarch64-w64-mingw32 target in fast_floatEvgeny Karpov1-1/+2
This patch resolves the GCC compilation issue for the C++ language targeting aarch64-w64-mingw32. The change in fast_float has been upstreamed. https://github.com/fastfloat/fast_float/pull/269 libstdc++-v3/ChangeLog: * src/c++17/fast_float/fast_float.h (full_multiplication): Support aarch64-w64-mingw32 target.
2025-04-11libstdc++: Use constexpr-if for std::basic_string::_S_copy_charsJonathan Wakely1-1/+2
For C++11 and later we can remove four overloads of _S_copy_chars and use constexpr-if in the generic _S_copy_chars. This simplifies overload resolution for _S_copy_chars, and also means that we use the optimized memcpy path for other iterators such as std::vector<char>::iterator. We still need all the _S_copy_chars overloads to be part of the explicit instantiation definition, so make them depend on the macro that is defined by src/c++11/string-inst.cc for that purpose. For C++98 the _S_copy_chars overloads are still needed, but the macros _GLIBCXX_NOEXCEPT and _GLIBCXX20_CONSTEXPR do nothing for C++98, so this change removes them from those overloads. When instantiated in src/c++11/string-inst.cc the removed _GLIBCXX_NOEXCEPT macros would expand to 'noexcept', but in practice that doesn't make any difference for those instantiations. At -O2 the instantiations inline all the calls to _S_copy_chars and the presence or absence of noexcept doesn't change anything in the generated code. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (_S_copy_chars): Replace overloads with constexpr-if and extend optimization to all contiguous iterators. * src/c++11/string-inst.cc: Extend comment. Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com>
2025-03-30Optimize string constructorJan Hubicka1-0/+8
this patch improves code generation on string constructors. We currently have _M_construct which takes as a parameter two iterators (begin/end pointers to other string) and produces new string. This patch adds special case of constructor where instead of begining/end pointers we readily know the string size and also special case when we know that source is 0 terminated. This happens commonly when producing stirng copies. Moreover currently ipa-prop is not able to propagate information that beg-end is known constant (copied string size) which makes it impossible for inliner to spot the common case where string size is known to be shorter than 15 bytes and fits in local buffer. Finally I made new constructor inline. Because it is explicitely instantiated without C++20 constexpr we do not produce implicit instantiation (as required by standard) which prevents inlining, ipa-modref and any other IPA analysis to happen. I think we need to make many of the other functions inline, since optimization accross string manipulation is quite important. There is PR94960 to track this issue. Bootstrapped/regtested x86_64-linux, OK? libstdc++-v3/ChangeLog: PR tree-optimization/103827 PR tree-optimization/80331 PR tree-optimization/87502 * config/abi/pre/gnu.ver: Add version for _M_construct<bool> * include/bits/basic_string.h: (basic_string::_M_construct<bool>): Declare. (basic_string constructors): Use it. * include/bits/basic_string.tcc: (basic_string::_M_construct<bool>): New template. * src/c++11/string-inst.cc: Instantated S::_M_construct<bool>. gcc/testsuite/ChangeLog: * g++.dg/tree-ssa/pr80331.C: New test. * g++.dg/tree-ssa/pr87502.C: New test.
2025-03-27libstdc++: Update tzdata to 2025bJonathan Wakely1-2/+16
Import the new 2025b tzdata.zi file. libstdc++-v3/ChangeLog: * src/c++20/tzdata.zi: Import new file from 2025b release.
2025-03-21libstdc++: Fix std.compat exports of <stdbit.h> and <stdckdint.h>Jonathan Wakely1-2/+9
libstdc++-v3/ChangeLog: * src/c++23/std.compat.cc.in: Only export <stdbit.h> and <stdckdint.h> contents for C++26 and later. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-03-21libstdc++: Add views::cache_latest and views::to_input to std moduleJonathan Wakely1-3/+20
Also export the tuple-like helpers from <complex>, and the std::from_range_t and std::from_range tag. libstdc++-v3/ChangeLog: * src/c++23/std.cc.in (tuple_element, tuple_element_t) (tuple_size, tuple_size_v, get): Export. (ranges::cache_latest_view, views::cache_latest): Export. (ranges::to_input_view, views::to_input): Export. (from_range_t, from_range): Export. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-03-13libstdc++: Implement <stdckdint.h> for C++26 (P3370R1)Jonathan Wakely1-0/+8
This is the second part of the P3370R1 proposal just approved by the committee in Wrocław. This adds C++ equivalents of the functions added to C23 by WG14 N2683. These functions are in the global namespace, but to avoid collisions with the same functions defined by other standard library implementations, this change defines them in namespace __gnu_cxx and then adds them to the global namespace. libstdc++-v3/ChangeLog: * include/Makefile.am: Add stdckdint.h. * include/Makefile.in: Regenerate. * src/c++23/std.compat.cc.in: Export <stdckdint.h> functions. * include/c_compatibility/stdckdint.h: New file. * testsuite/26_numerics/stdckdint/1.cc: New test. * testsuite/26_numerics/stdckdint/2_neg.cc: New test. Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-03-13libstdc++: Implement <stdbit.h> for C++26 (P3370R1)Jonathan Wakely1-0/+29
This is the first part of the P3370R1 proposal just approved by the committee in Wrocław. This adds C++ equivalents of the functions added to C23 by WG14 N3022. These functions are in the global namespace, but to avoid collisions with the same functions defined by other standard library implementations, this change defines them in namespace __gnu_cxx and then adds them to the global namespace. libstdc++-v3/ChangeLog: * include/Makefile.am: Add stdbit.h. * include/Makefile.in: Regenerate. * src/c++23/std.compat.cc.in: Export <stdbit.h> functions. * include/c_compatibility/stdbit.h: New file. * testsuite/20_util/stdbit/1.cc: New test. * testsuite/20_util/stdbit/2_neg.cc: New test. Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-03-12libstdc++: Update tzdata to 2025aJonathan Wakely2-847/+839
Import the new 2025a tzdata.zi file. The leapseconds file was also updated to have a new expiry (no new leap seconds were added). libstdc++-v3/ChangeLog: * include/std/chrono (__detail::__get_leap_second_info): Update expiry date for leap seconds list. * src/c++20/tzdata.zi: Import new file from 2025a release. * src/c++20/tzdb.cc (tzdb_list::_Node::_S_read_leap_seconds) Update expiry date for leap seconds list.
2025-03-06Fix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS && ↵Jonathan Wakely1-1/+11
!__GTHREADS_CXX0X' configurations libstdc++-v3/ * src/c++20/tzdb.cc [__GTHREADS && !__GTHREADS_CXX0X]: Use '__gnu_cxx::__mutex'. Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
2025-03-06libstdc++: Avoid '-Wunused-parameter' for 'out' in member function ↵Thomas Schwinge1-1/+1
'std::codecvt_base::result std::__format::{anonymous}::__encoding::conv(std::string_view, std::string&) const' In a newlib configuration: ../../../../../source-gcc/libstdc++-v3/src/c++20/format.cc: In member function ‘std::codecvt_base::result std::__format::{anonymous}::__encoding::conv(std::string_view, std::string&) const’: ../../../../../source-gcc/libstdc++-v3/src/c++20/format.cc:100:35: error: unused parameter ‘out’ [-Werror=unused-parameter] 100 | conv(string_view input, string& out) const | ~~~~~~~~^~~ libstdc++-v3/ * src/c++20/format.cc (conv): Tag 'out' as '[[maybe_unused]]'.
2025-03-06libstdc++: Avoid '-Wunused-parameter' for 'is_directory' in member function ↵Thomas Schwinge1-1/+1
'bool std::filesystem::__cxx11::_Dir::do_unlink(bool, std::error_code&) const' In a newlib configuration: ../../../../../source-gcc/libstdc++-v3/src/c++17/fs_dir.cc: In member function ‘bool std::filesystem::__cxx11::_Dir::do_unlink(bool, std::error_code&) const’: ../../../../../source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:147:18: error: unused parameter ‘is_directory’ [-Werror=unused-parameter] 147 | do_unlink(bool is_directory, error_code& ec) const noexcept | ~~~~~^~~~~~~~~~~~ libstdc++-v3/ * src/c++17/fs_dir.cc (do_unlink): Tag 'is_directory' as '[[maybe_unused]]'.
2025-03-06libstdc++: Avoid '-Wunused-parameter' for 'nofollow' in static member ↵Thomas Schwinge1-1/+1
function 'static std::filesystem::__gnu_posix::DIR* std::filesystem::_Dir_base::openat(const _At_path&, bool)' In a newlib configuration: In file included from ../../../../../source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:37, from ../../../../../source-gcc/libstdc++-v3/src/c++17/cow-fs_dir.cc:26: ../../../../../source-gcc/libstdc++-v3/src/c++17/../filesystem/dir-common.h: In static member function ‘static std::filesystem::__gnu_posix::DIR* std::filesystem::_Dir_base::openat(const _At_path&, bool)’: ../../../../../source-gcc/libstdc++-v3/src/c++17/../filesystem/dir-common.h:210:36: error: unused parameter ‘nofollow’ [-Werror=unused-parameter] 210 | openat(const _At_path& atp, bool nofollow) | ~~~~~^~~~~~~~ libstdc++-v3/ * src/filesystem/dir-common.h (openat): Tag 'nofollow' as '[[maybe_unused]]'.
2025-03-05libstdc++: fix possible undefined std::timespec in module stdyxj-github-4371-1/+1
I notice std::timespec and std::timespec_get are used in preprocessor condition _GLIBCXX_HAVE_TIMESPEC_GET. So in module std, it should be the same. libstdc++-v3: * src/c++23/std-clib.cc.in (timespec): Move within preprocessor group guarded by _GLIBCXX_HAVE_TIMESPEC_GET.
2025-02-22libstdc++: Fix bootstrap failure with --enable-vtable-verify [PR118981]Jonathan Wakely1-3/+3
The compiler emits code with init_priority(99) for -fvtable-verify=std and that creates a section conflict with the uses of init_priority(99) that I recently added to src/c++20/tzdb.cc. Change tzdb.cc to use a different priority to avoid the conflict. libstdc++-v3/ChangeLog: PR c++/118981 * src/c++20/tzdb.cc: Use init_priority(98) instead of init_priority(99).
2025-02-22libstdc++: Remove redundant cast in floating_from_chars.ccJonathan Wakely1-2/+1
In r15-7647-g32457bc25fea80 I added a cast and also changed the type of the variable, making the cast redundant. This removes the cast. libstdc++-v3/ChangeLog: * src/c++17/floating_from_chars.cc (__floating_from_chars_hex): Remove redundant cast.
2025-02-20libstdc++: Fix invalid signed arguments to <bit> functionsJonathan Wakely2-3/+5
These should have been unsigned, but the static assertions are only in the public std::bit_ceil and std::bit_width functions, not the internal __bit_ceil and __bit_width ones. libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h (__find_next_valid_abi): Cast __bit_ceil argument to unsigned. * src/c++17/floating_from_chars.cc (__floating_from_chars_hex): Cast __bit_ceil argument to unsigned. * src/c++17/memory_resource.cc (big_block): Cast __bit_width argument to unsigned.
2025-02-20libstdc++: Remove workaround for reserved init_priority warningsJonathan Wakely4-30/+14
Since r15-7511-g4e7f74225116e7 we can disable the warnings for using a reserved priority using a diagnostic pragma. That means we no longer need to put globals using that attribute into separate files that get included. This replaces the two uses of such separate files by moving the variable definition into the source file and adding the diagnostic pragma. libstdc++-v3/ChangeLog: * src/c++17/memory_resource.cc (default_res): Define here instead of including default_resource.h. * src/c++98/globals_io.cc (__ioinit): Define here instead of including ios_base_init.h. * src/c++17/default_resource.h: Removed. * src/c++98/ios_base_init.h: Removed.
2025-02-20libstdc++: Use init_priority attribute for tzdb globals [PR118811]Jonathan Wakely1-4/+7
When linking statically to libstdc++.a (or to libstdc++_nonshared.a in the RHEL devtoolset compiler) there's a static initialization order problem where user code might be constructed before the std::chrono::tzdb_list globals, and so might try to use them after they've already been destroyed. Use the init_priority attribute on those globals so that they are initialized early. Since r15-7511-g4e7f74225116e7 we can disable the warnings for using a reserved priority using a diagnostic pragma. libstdc++-v3/ChangeLog: PR libstdc++/118811 * src/c++20/tzdb.cc (tzdb_list::_Node): Use init_priority attribute on static data members. * testsuite/std/time/tzdb_list/pr118811.cc: New test.