aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
AgeCommit message (Collapse)AuthorFilesLines
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-23Daily bump.GCC Administrator1-0/+55
2025-04-22Revert "libstdc++: Optimize std::projected<I, std::identity>" [PR119888]Patrick Palka2-10/+0
This non-standard optimization breaks real-world code that expects the result of std::projected to always (be a class type and) have a value_type member, which isn't true for e.g. I=int*, so revert it for now. PR libstdc++/119888 This reverts commit 51761c50f843d5be4e24172535e4524b5072f24c.
2025-04-22libstdc++: Update baseline symbols for m68k-linuxAndreas Schwab1-0/+11
* config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Update.
2025-04-22libstdc++: Update baseline symbols for riscv64-linuxAndreas Schwab1-0/+15
* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Update.
2025-04-22libstdc++: Update Linux/sparc64 baselines for GCC 15.1Rainer Orth2-2/+432
The Linux/sparc64 libstdc++ baselines haven't been updated for years. This patch fixes that. Tested on sparc64-unknown-linux-gnu on both the gcc-15 branch and trunk. 2025-04-21 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> libstdc++-v3: * config/abi/post/sparc64-linux-gnu/baseline_symbols.txt: Regenerate. * config/abi/post/sparc64-linux-gnu/32/baseline_symbols.txt: Likewise.
2025-04-22libstdc++: Update Solaris baselines for GCC 15.1Rainer Orth4-0/+44
This patch updates the Solaris libstdc++ baselines for GCC 15.1. Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 on both the gcc-15 branch and trunk. 2025-02-11 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> libstdc++-v3: * config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate. * config/abi/post/i386-solaris/amd64/baseline_symbols.txt: Likewise. * config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise. * config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt: Likewise.
2025-04-22libstdc++: Update baseline_symbols.txt for ↵Jakub Jelinek6-0/+66
{x86_64,i486,powerpc64le,s390x,aarch64}-linux We forgot to update these timely, sorry for that, the following patch updates them from the 15.1-rc1 builds in Fedora. 2025-04-22 Jakub Jelinek <jakub@redhat.com> * config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Update. * config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt: Update. * config/abi/post/i486-linux-gnu/baseline_symbols.txt: Update. * config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Update. * config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Update. * config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt: Update.
2025-04-22libstdc++: Increase timeouts for format and flat_maps testsTomasz Kamiński5-0/+5
Test for format parse format string and compile time, flat_maps ones test all functionality in single test file. libstdc++-v3/ChangeLog: * testsuite/23_containers/flat_map/1.cc: Add dg-timeout-factor 2. * testsuite/23_containers/flat_multimap/1.cc: Likewise. * testsuite/std/format/ranges/map.cc: Likewise. * testsuite/std/format/ranges/sequence.cc: Likewise. * testsuite/std/format/ranges/string.cc: Likewise.
2025-04-22libstdc++: Finalize GCC 15 ABIAndreas Schwab1-2/+2
Disallow adding new symbols to GLIBCXX_3.4.34 and CXXABI_1.3.16 versions. * testsuite/util/testsuite_abi.cc (check_version): Update latestp to use GLIBCXX_3.4.35 and CXXABI_1.3.17.
2025-04-19Daily bump.GCC Administrator1-0/+76
2025-04-18libstdc++: Add _GLIBCXX_DEBUG checks on unordered container local_iteratorFrançois Dumont33-49/+531
Complete tests on _GLIBCXX_DEBUG checks in include/debug/safe_local_iterator.h. Fix several tests not testing the container corresponding to their location in the testsuite directory. libstdc++-v3/ChangeLog: * testsuite/util/debug/unordered_checks.h (fill_container): New helper method. (use_erased_local_iterator, invalid_local_iterator_pre_increment) (invalid_local_iterator_post_increment, invalid_local_iterator_compare) (invalid_local_iterator_range): Use latter. (fill_and_get_local_iterator): New, use fill_container. (use_invalid_local_iterator): Use latter. (invalid_local_iterator_arrow_operator): New test function. (invalid_local_iterator_copy_instantiation): New test function. (invalid_local_iterator_move_instantiation): New test function. (invalid_local_iterator_copy_assignment): New test function. (invalid_local_iterator_move_assignment): New test function. (invalid_local_iterator_const_conversion): New test function. * testsuite/23_containers/unordered_map/debug/invalid_local_iterator_arrow_operator_neg.cc: New test case. * testsuite/23_containers/unordered_map/debug/invalid_local_iterator_const_conversion_neg.cc: New test case. * testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_assignment_neg.cc: New test case. * testsuite/23_containers/unordered_map/debug/invalid_local_iterator_copy_construction_neg.cc: New test case. * testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_assignment_neg.cc: New test case. * testsuite/23_containers/unordered_map/debug/invalid_local_iterator_move_construction_neg.cc: New test case. * testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc: Test unordered_map. * testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc: Test unordered_multimap. * testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc: Likewise. * testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc: Likewise. * testsuite/23_containers/unordered_multimap/debug/cend_neg.cc: Likewise. * testsuite/23_containers/unordered_multimap/debug/end1_neg.cc: Likewise. * testsuite/23_containers/unordered_multimap/debug/end2_neg.cc: Likewise. * testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_arrow_operator_neg.cc: New test case. * testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_const_conversion_neg.cc: New test case. * testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_assignment_neg.cc: New test case. * testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_copy_construction_neg.cc: New test case. * testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_assignment_neg.cc: New test case. * testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_move_construction_neg.cc: New test case. * testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc: Test unordered_multimap. * testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_arrow_operator_neg.cc: New test case. * testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_const_conversion_neg.cc: New test case. * testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_assignment_neg.cc: New test case. * testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_copy_construction_neg.cc: New test case. * testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_assignment_neg.cc: New test case. * testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_move_construction_neg.cc: New test case. * testsuite/23_containers/unordered_set/debug/invalid_local_iterator_arrow_operator_neg.cc: New test case. * testsuite/23_containers/unordered_set/debug/invalid_local_iterator_const_conversion_neg.cc: New test case. * testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_assignment_neg.cc: New test case. * testsuite/23_containers/unordered_set/debug/invalid_local_iterator_copy_construction_neg.cc: New test case. * testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_assignment_neg.cc: New test case. * testsuite/23_containers/unordered_set/debug/invalid_local_iterator_move_construction_neg.cc: New test case. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2025-04-18libstdc++: Clarify that _S_ prefix is be used for static member functions.Tomasz Kamiński1-1/+1
libstdc++-v3/ChangeLog: * doc/xml/manual/appendix_contributing.xml: Add 'and functions'.
2025-04-18Daily bump.GCC Administrator1-0/+26
2025-04-17c++: improve pack index diagnosticsJason Merrill1-1/+1
While looking at pack-indexing16.C I thought it would be helpful to print the problematic type/value. gcc/cp/ChangeLog: * semantics.cc (finish_type_pack_element): Add more info to diagnostics. libstdc++-v3/ChangeLog: * testsuite/20_util/tuple/element_access/get_neg.cc: Adjust diagnostic. gcc/testsuite/ChangeLog: * g++.dg/cpp26/pack-indexing2.C: Adjust diagnostics. * g++.dg/ext/type_pack_element2.C: Likewise. * g++.dg/ext/type_pack_element4.C: Likewise.
2025-04-17libstdc++: Fixed signed comparision in _M_parse_fill_and_align [PR119840]Tomasz Kamiński1-2/+2
Explicitly cast elements of __not_fill to _CharT. Only '{' and ':' are used as `__not_fill`, so they are never negative. PR libstdc++/119840 libstdc++-v3/ChangeLog: * include/std/format (_M_parse_fill_and_align): Cast elements of __not_fill to _CharT.
2025-04-17libstdc++: Do not use 'not' alternative token in <format>Jonathan Wakely2-1/+17
This fixes: FAIL: 17_intro/headers/c++1998/operator_names.cc -std=gnu++23 (test for excess errors) FAIL: 17_intro/headers/c++1998/operator_names.cc -std=gnu++26 (test for excess errors) The purpose of 'not defined<format_kind<R>>' is to be ill-formed (as required by [format.range.fmtkind]) and to give an error that includes the string "not defined<format_kind<R>>". That was intended to tell you that format_kind<R> is not defined, just like it says! But user code can use -fno-operator-names so we can't use 'not' here, and "! defined" in the diagnostic doesn't seem as user-friendly. It also raises questions about whether it was intended to be the preprocessor token 'defined' (it's not) or where 'defined' is defined (it's not). Replace it with __primary_template_not_defined<format_kind<R>> and a comment, which seems to give a fairly clear diagnostic with both GCC and Clang. The diagnostic now looks like: .../include/c++/15.0.1/format:5165:7: error: use of 'std::format_kind<int>' before deduction of 'auto' 5165 | format_kind<_Rg> // you can specialize this for non-const input ranges | ^~~~~~~~~~~~~~~~ .../include/c++/15.0.1/format:5164:35: error: '__primary_template_not_defined' was not declared in this scope 5164 | __primary_template_not_defined( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 5165 | format_kind<_Rg> // you can specialize this for non-const input ranges | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5166 | ); | ~ libstdc++-v3/ChangeLog: * include/std/format (format_kind): Do not use 'not' alternative token to make the primary template ill-formed. Use the undeclared identifier __primary_template_not_defined and a comment that will appear in diagnostics. * testsuite/std/format/ranges/format_kind_neg.cc: New test.
2025-04-17libstdc++: Remove dead code in range_formatter::format [PR109162]Tomasz Kamiński1-7/+12
Because the _M_format(__rg, __fc) were placed outside of if constexpr, these method and its children where instantiated, even if _M_format<const _Range> could be used. To simplify the if constexpr chain, we introduce a __simply_formattable_range (name based on simple-view) exposition only concept, that checks if range is const and mutable formattable and uses same formatter specialization for references in each case. PR libstdc++/109162 libstdc++-v3/ChangeLog: * include/std/format (__format::__simply_formattable_range): Define. (range_formatter::format): Do not instantiate _M_format for mutable _Rg if const _Rg can be used. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-17Daily bump.GCC Administrator1-0/+34
2025-04-16libstdc++: Fix constification in range_formatter::format [PR109162]Tomasz Kamiński2-3/+30
The _Rg is deduced to lvalue reference for the lvalue arguments, and in such case __format::__maybe_const_range<_Rg, _CharT> is always _Rg (adding const to reference does not change behavior). Now we correctly check if _Range = remove_reference_t<_Rg> is const formattable range, furthermore as range_formatter<T> can only format ranges of values of type (possibly const) _Tp, we additional check if the remove_cvref_t<range_reference_t<const _Range>> is _Tp. The range_reference_t<R> and range_reference_t<const R> have different types (modulo remove_cvref_t) for std::vector<bool> (::reference and bool) or flat_map<T, U> (pair<const T&, U&> and pair<const T&, const U&>). PR libstdc++/109162 libstdc++-v3/ChangeLog: * include/std/format (range_formatter::format): Format const range, only if reference type is not changed. * testsuite/std/format/ranges/formatter.cc: New tests. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-16libstdc++: Implement formatters for pair and tuple [PR109162]Tomasz Kamiński6-93/+813
This patch implements formatter specializations for pair and tuple form P2286R8. In addition using 'm` and range_format::map (from P2585R1) for ranges are now supported. The formatters for pairs and tuples whose corresponding elements are the same (after applying remove_cvref_t) derive from the same __tuple_formatter class. This reduce the code duplication, as most of the parsing and formatting is the same in such cases. We use a custom reduced implementation of the tuple (__formatters_storage) to store the elements formatters. Handling of the padding (width and fill) options, is extracted to __format::__format_padded function, that is used both by __tuple_formatter and range_formatter. To reduce number of instantations range_formatter::format triggers, we cast incoming range to __format::__maybe_const_range<_Rg, _CharT>&, before formatting it. As in the case of previous commits, the signatures of the user-facing parse and format methods of the provided formatters deviate from the standard by constraining types of parameters: * _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. Finally, test for tuple-like std::array and std::ranges::subrange, that illustrate that they remain formatted as ranges. PR libstdc++/109162 libstdc++-v3/ChangeLog: * include/std/format (__formatter_int::_M_format_character_escaped) (__formatter_str::format): Use __sink.out() to produce _Sink_iter. (__format::__const_formattable_range): Moved closer to range_formatter. (__format::__maybe_const_range): Use `__conditional_t` and moved closer to range_formatter. (__format::__format_padded, __format::maybe_const) (__format::__indexed_formatter_storage, __format::__tuple_formatter) (std::formatter<pair<_Fp, _Sp>, _CharT>>) (std::formatter<tuple<_Tps...>, _CharT): Define. (std::formatter<_Rg, _CharT>::format): Cast incoming range to __format::__maybe_const_range<_Rg, _CharT>&. (std::formatter<_Rg, _CharT>::_M_format): Extracted from format, and use __format_padded. (std::formatter<_Rg, _CharT>::_M_format_no_padding): Rename... (std::formatter<_Rg, _CharT>::_M_format_elems): ...to this. (std::formatter<_Rg, _CharT>::_M_format_with_padding): Extracted as __format_padded. * testsuite/util/testsuite_iterators.h (test_input_range_nocopy): Define. * testsuite/std/format/ranges/formatter.cc: Tests for `m` specifier. * testsuite/std/format/ranges/sequence.cc: Tests for array and subrange. * testsuite/std/format/ranges/map.cc: New test. * testsuite/std/format/tuple.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-16Daily bump.GCC Administrator1-0/+61
2025-04-15libstdc++: Do not define __cpp_lib_ranges_iota in <ranges>Jonathan Wakely1-1/+0
In r14-7153-gadbc46942aee75 we removed a duplicate definition of __glibcxx_want_range_iota from <ranges>, but __cpp_lib_ranges_iota should be defined in <ranges> at all. libstdc++-v3/ChangeLog: * include/std/ranges (__glibcxx_want_ranges_iota): Do not define.
2025-04-15libstdc++: Do not declare namespace ranges in <numeric> unconditionallyJonathan Wakely2-5/+7
Move namespace ranges inside the feature test macro guard, because 'ranges' is not a reserved name before C++20. libstdc++-v3/ChangeLog: * include/std/numeric (ranges): Only declare namespace for C++23 and later. (ranges::iota_result): Fix indentation. * testsuite/17_intro/names.cc: Check ranges is not used as an identifier before C++20.
2025-04-15libstdc++: Implement formatter for ranges and range_formatter [PR109162]Tomasz Kamiński9-65/+1125
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-15libstdc++: Fix std::string construction from volatile char* [PR119748]Jonathan Wakely5-13/+73
My recent r15-9381-g648d5c26e25497 change assumes that a contiguous iterator with the correct value_type can be converted to a const charT* but that's not true for volatile charT*. The optimization should only be done if it can be converted to the right pointer type. Additionally, some generic loops for non-contiguous iterators need an explicit cast to deal with iterator reference types that do not bind to the const charT& parameter of traits_type::assign. libstdc++-v3/ChangeLog: PR libstdc++/119748 * include/bits/basic_string.h (_S_copy_chars): Only optimize for contiguous iterators that are convertible to const charT*. Use explicit conversion to charT after dereferencing iterator. (_S_copy_range): Likewise for contiguous ranges. * include/bits/basic_string.tcc (_M_construct): Use explicit conversion to charT after dereferencing iterator. * include/bits/cow_string.h (_S_copy_chars): Likewise. (basic_string(from_range_t, R&&, const Allocator&)): Likewise. Only optimize for contiguous iterators that are convertible to const charT*. * testsuite/21_strings/basic_string/cons/char/119748.cc: New test. * testsuite/21_strings/basic_string/cons/wchar_t/119748.cc: New test. Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com>
2025-04-15libstdc++: Enable __gnu_test::test_container constructor for C++98Jonathan Wakely1-3/+1
The only reason this constructor wasn't defined for C++98 is that it uses constructor delegation, but that isn't necessary. libstdc++-v3/ChangeLog: * testsuite/util/testsuite_iterators.h (test_container): Define array constructor for C++98 as well.
2025-04-15Daily bump.GCC Administrator1-0/+13
2025-04-14libstdc++: Document thread-safety for COW std::string [PR21334]Jonathan Wakely2-0/+22
The gcc4-compatible copy-on-write std::string does not conform to the C++11 requirements on data race avoidance in standard containers. Specifically, calling non-const member functions such as begin() and data() needs to do the "copy on write" operation and so is most definitely a modification of the object. As such, those non-const members must not be called concurrently with any other uses of the string object. libstdc++-v3/ChangeLog: PR libstdc++/21334 * doc/xml/manual/using.xml: Document that container data race avoidance rules do not apply to COW std::string. * doc/html/*: Regenerate.
2025-04-14libstdc++: Use UTF-32BE as wide encoding for big-endian machines [PR119725]Tomasz Kamiński2-2/+3
This changes the `dg-options` line so UTF-32 with byte order native to the machine is used as wide encoding. We still do not handle mismatch in the byte order of the Unicode encodings (UTF32-BE on little-endian machines). This would require larger changes, as for example `unicode-data.h` tables are encoded with native byte order. PR libstdc++/119725 libstdc++-v3/ChangeLog: * testsuite/std/format/debug.cc: Updated dg-options. * testsuite/std/format/debug_nonunicode.cc: Updated dg-options. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-12Daily bump.GCC Administrator1-0/+138
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 Wakely2-9/+25
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-04-11libstdc++: Define __cpp_lib_containers_ranges in appropriate headers [PR111055]Tomasz Kamiński58-146/+254
This is final piece of P1206R7, adding a feature test macros, as range constructors and member operations are now implemented for all containers and adaptors. For consistency with the proposal, all new container operations and helpers are now defined if __glibcxx_containers_ranges, instead of __glibcxx_ranges_to_container. PR libstdc++/111055 libstdc++-v3/ChangeLog: * include/bits/version.def (containers_ranges): Define. * include/bits/version.h: Regenerate. * include/bits/ranges_base.h (__detail::__container_compatible_range) (__detail::__range_to_alloc_type, __detail::__range_mapped_type) (__detail::__range_key_type): Depend on __glibcxx_containers_ranges instead of __glibcxx_ranges_to_container. * include/bits/basic_string.h: Replace __glibcxx_ranges_to_container with __glibcxx_containers_ranges. * include/bits/cow_string.h: Likewise. * include/bits/deque.tcc: Likewise. * include/bits/forward_list.h: Likewise. * include/bits/stl_bvector.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_map.h: Likewise. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_queue.h: Likewise. * include/bits/stl_set.h: Likewise. * include/bits/stl_stack.h: Likewise. * include/bits/stl_vector.h: Likewise. * include/bits/unordered_map.h: Likewise. * include/bits/unordered_set.h: Likewise. * include/bits/vector.tcc: Likewise. * include/debug/deque: Likewise. * include/debug/forward_list: Likewise. * include/debug/list: Likewise. * include/debug/map.h: Likewise. * include/debug/multimap.h: Likewise. * include/debug/multiset.h: Likewise. * include/debug/set.h: Likewise. * include/debug/unordered_map: Likewise. * include/debug/unordered_set: Likewise. * include/debug/vector: Likewise. * include/std/deque: Provide __cpp_lib_containers_ranges. * include/std/forward_list: Likewise. * include/std/list: Likewise. * include/std/map: Likewise. * include/std/queue: Likewise. * include/std/set: Likewise. * include/std/stack: Likewise. * include/std/string: Likewise. * include/std/unordered_map: Likewise. * include/std/unordered_set: Likewise. * include/std/vector: Likewise. * testsuite/21_strings/basic_string/cons/from_range.cc: Test for value __cpp_lib_containers_ranges. * testsuite/23_containers/deque/cons/from_range.cc: Likewise. * testsuite/23_containers/forward_list/cons/from_range.cc: Likewise. * testsuite/23_containers/list/cons/from_range.cc: Likewise. * testsuite/23_containers/map/cons/from_range.cc: Likewise. * testsuite/23_containers/multimap/cons/from_range.cc: Likewise. * testsuite/23_containers/multiset/cons/from_range.cc: Likewise. * testsuite/23_containers/priority_queue/cons_from_range.cc: Likewise. * testsuite/23_containers/queue/cons_from_range.cc: Likewise. * testsuite/23_containers/set/cons/from_range.cc: Likewise. * testsuite/23_containers/stack/cons_from_range.cc: Likewise. * testsuite/23_containers/unordered_map/cons/from_range.cc: Likewise. * testsuite/23_containers/unordered_multimap/cons/from_range.cc: Likewise. * testsuite/23_containers/unordered_multiset/cons/from_range.cc: Likewise. * testsuite/23_containers/unordered_set/cons/from_range.cc: Likewise. * testsuite/23_containers/vector/bool/cons/from_range.cc: Likewise. * testsuite/23_containers/vector/cons/from_range.cc: Likewise. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-11libstdc++: Add P1206R7 from_range members to std::string [PR111055]Jonathan Wakely7-0/+925
This is the last piece of P1206R7, adding new members to std::basic_string. libstdc++-v3/ChangeLog: PR libstdc++/111055 * include/bits/basic_string.h (_S_copy_range): New function. (basic_string(from_range_t, R%%, const Alloc&)): New constructor. (append_range, assign_range, insert_range, replace_with_range): New functions. * include/bits/cow_string.h: Likewise. * testsuite/21_strings/basic_string/cons/from_range.cc: New test. * testsuite/21_strings/basic_string/modifiers/append/append_range.cc: New test. * testsuite/21_strings/basic_string/modifiers/assign/assign_range.cc: New test. * testsuite/21_strings/basic_string/modifiers/insert/insert_range.cc: New test. * testsuite/21_strings/basic_string/modifiers/replace/replace_with_range.cc: New test. Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-11libstdc++: Implement debug format for strings and characters formatters ↵Tomasz Kamiński9-81/+1170
[PR109162] This patch implements part P2286R8 that specified debug (escaped) format for the strings and characters sequences. This include both handling of the '?' format specifier and set_debug_format member. To indicate partial support we define __glibcxx_format_ranges macro value 1, without defining __cpp_lib_format_ranges. We provide two separate escaping routines depending on the literal encoding for the corresponding character types. If the character encoding is Unicode, we follow the specification for the standard (__format::__write_escaped_unicode). For other encodings, we escape only characters in range [0x00, 0x80), interpreting them as ASCII values: [0x00, 0x20), 0x7f and '\t', '\r', '\n', '\\', '"', '\'' are escaped. We assume every character outside this range is printable (__format::_write_escaped_ascii). In particular we do not yet implement special handling of shift sequences. For Unicode escaping a new __unicode::__escape_edges table is introduced, that encodes information if character belongs to General_Category that is escaped by the standard (Control or Other). This table is generated from DerivedGeneralCategory.txt provided by Unicode. Only boolean flag is preserved to reduce the number of entries. The additional rules for escaping are handled by __format::__should_escape_unicode. When width or precision is specified, we emit escaped string to the temporary buffer and format the resulting string according to the format spec. For characters use a fixed size stack buffer, for which a new _Fixedbuf_sink is introduced. For strings, we use _Str_sink and to avoid allocations, we compute the estimated size of (possibly truncated) input, and if it is larger than width field we print directly. PR libstdc++/109162 contrib/ChangeLog: * unicode/README: Mentioned DerivedGeneralCategory.txt. * unicode/gen_libstdcxx_unicode_data.py: Generation __escape_edges table from DerivedGeneralCategory.txt. Update file name in comments. * unicode/DerivedGeneralCategory.txt: Copy of file distributed by Unicode Consortium. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (__detail::_Widen): Moved to std/format file. * include/bits/unicode-data.h: Regnerate. * include/bits/unicode.h (__unicode::_Utf_iterator::_M_units) (__unicode::__should_escape_category): Define. * include/std/format (_GLIBCXX_WIDEN_, _GLIBCXX_WIDEN): Copied from include/bits/chrono_io.h. (__format::_Widen): Moved from include/bits/chrono_io.h. (__format::_Term_char, __format::_Escapes, __format::_Separators) (__format::__should_escape_ascii, __format::__should_escape_unicode) (__format::__write_escape_seq, __format::__write_escaped_char) (__format::__write_escaped_acii, __format::__write_escaped_unicode) (__format::__write_escaped): Define. (__formatter_str::_S_trunc): Extracted truncation of character sequences. (__formatter_str::format): Handle _Pres_esc. (__formatter_int::_M_do_parse) [__glibcxx_format_ranges]: Parse '?'. (__formatter_int::_M_format_character_escaped): Define. (formatter<_CharT, _CharT>::format, formatter<char, wchar_t>::format): Handle _Pres_esc. (__formatter_str::set_debug_format, formatter<...>::set_debug_format) Guard with __glibcxx_format_ranges. (__format::_Fixedbuf_sink): Define. * testsuite/23_containers/vector/bool/format.cc: Use __format::_Widen and remove unnecessary <chrono> include. * testsuite/std/format/debug.cc: New test. * testsuite/std/format/debug_nonunicode.cc: New test. * testsuite/std/format/parse_ctx.cc (escaped_strings_supported): Define to true if __glibcxx_format_ranges is defined. * testsuite/std/format/string.cc (escaped_strings_supported): Define to true if __glibcxx_format_ranges is defined. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-11Daily bump.GCC Administrator1-0/+13
2025-04-10libstdc++: Adjust value of __cpp_lib_constrained_equality for C++20Jonathan Wakely3-3/+13
The P3379R0 bump to __cpp_lib_constrained_equality relates to changes that only affect std::expected, so there's no reason to define the updated value in C++20. This change restores the previous value (202403) for C++20, and only uses the new value (202411) for C++23 and later. Also remove the TODO comments, because I correctly predicted that the final value would be 202411. libstdc++-v3/ChangeLog: * include/bits/version.def (constrained_equality): Only define as 202411 for C++23 and later, use 202403 for C++20. * include/bits/version.h: Regenerate. * testsuite/20_util/expected/equality_constrained.cc: Remove TODO comment.
2025-04-10hpux: Remove _GLIBCXX_USE_LONG_LONG define from hpux os_defines.hJohn David Anglin1-6/+1
_GLIBCXX_USE_LONG_LONG is now defined by configure. 2025-04-05 John David Anglin <danglin@gcc.gnu.org> libstdc++-v3/ChangeLog: * config/os/hpux/os_defines.h: Remove _GLIBCXX_USE_LONG_LONG define.
2025-04-10Daily bump.GCC Administrator1-0/+10
2025-04-09libstdc++: Fix constraint recursion in basic_const_iterator operator- [PR115046]Patrick Palka2-2/+15
It was proposed in PR112490 to also adjust basic_const_iterator's friend operator-(sent, iter) overload alongside the r15-7757-g4342c50ca84ae5 adjustments to its comparison operators, but we lacked a concrete testcase demonstrating fixable constraint recursion there. It turns out Hewill Kang's PR115046 is such a testcase! So this patch makes the same adjustments to that overload as well, fixing PR115046. The LWG 4218 P/R will need to get adjusted too. PR libstdc++/115046 PR libstdc++/112490 libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (basic_const_iterator::operator-): Replace non-dependent basic_const_iterator function parameter with a dependent one of type basic_const_iterator<_It2> where _It2 matches _It. * testsuite/std/ranges/adaptors/as_const/1.cc (test04): New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2025-04-09Daily bump.GCC Administrator1-0/+8
2025-04-08libstdc++: Fix use-after-free in std::format [PR119671]Jonathan Wakely2-3/+15
When formatting floating-point values to wide strings there's a case where we invalidate a std::wstring buffer while a std::wstring_view is still referring to it. libstdc++-v3/ChangeLog: PR libstdc++/119671 * include/std/format (__formatter_fp::format): Do not invalidate __wstr unless _M_localized returns a valid string. * testsuite/std/format/functions/format.cc: Check wide string formatting of floating-point types with classic locale. Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com>
2025-04-08Daily bump.GCC Administrator1-0/+24
2025-04-07libstdc++: Remove stray pragma in new header [PR119642]Jonathan Wakely1-1/+0
libstdc++-v3/ChangeLog: PR libstdc++/119642 * include/bits/formatfwd.h: Remove stray pragma.
2025-04-07libstdc++: Add new headers to <bits/stdc++.h> for PCHJonathan Wakely1-3/+3
This adds the new C23 headers to the PCH, and also removes the __has_include check for <stacktrace> because we provide that unconditionally now. libstdc++-v3/ChangeLog: * include/precompiled/stdc++.h: Include <stdbit.h> and <stdckdint.h>. Include <stacktrace> unconditionally.
2025-04-07libstdc++: Add new headers to Doxygen config fileJonathan Wakely1-0/+5
libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (INPUT): Add flat_map, flat_set, text_encoding, stdbit.h and stdckdint.h.
2025-04-07GCN, nvptx libstdc++: Force use of '__atomic' builtins [PR119645]Thomas Schwinge3-8/+21
For both GCN, nvptx, this gets rid of 'configure'-time: configure: WARNING: No native atomic operations are provided for this platform. configure: WARNING: They will be faked using a mutex. configure: WARNING: Performance of certain classes will degrade as a result. ..., and changes: -checking for lock policy for shared_ptr reference counts... mutex +checking for lock policy for shared_ptr reference counts... atomic That means, '[...]/[target]/libstdc++-v3/', 'Makefile's change: -ATOMICITY_SRCDIR = config/cpu/generic/atomicity_mutex +ATOMICITY_SRCDIR = config/cpu/generic/atomicity_builtins ..., and '[...]/[target]/libstdc++-v3/config.h' changes: /* Defined if shared_ptr reference counting should use atomic operations. */ -/* #undef HAVE_ATOMIC_LOCK_POLICY */ +#define HAVE_ATOMIC_LOCK_POLICY 1 /* Define if the compiler supports C++11 atomics. */ -/* #undef _GLIBCXX_ATOMIC_BUILTINS */ +#define _GLIBCXX_ATOMIC_BUILTINS 1 ..., and '[...]/[target]/libstdc++-v3/include/[target]/bits/c++config.h' changes: /* Defined if shared_ptr reference counting should use atomic operations. */ -/* #undef _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY */ +#define _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1 /* Define if the compiler supports C++11 atomics. */ -/* #undef _GLIBCXX_ATOMIC_BUILTINS */ +#define _GLIBCXX_ATOMIC_BUILTINS 1 This means that '[...]/[target]/libstdc++-v3/libsupc++/atomicity.cc', '[...]/[target]/libstdc++-v3/libsupc++/atomicity.o' then uses atomic instructions for synchronization instead of C++ static local variables, which in turn for their guard variables, via 'libstdc++-v3/libsupc++/guard.cc', used 'libgcc/gthr.h' recursive mutexes, which currently are unsupported for GCN. For GCN, this turns ~500 libstdc++ execution test FAILs into PASSes, and also progresses: PASS: g++.dg/tree-ssa/pr20458.C -std=gnu++17 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C -std=gnu++17 execution test PASS: g++.dg/tree-ssa/pr20458.C -std=gnu++26 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C -std=gnu++26 execution test UNSUPPORTED: g++.dg/tree-ssa/pr20458.C -std=gnu++98: exception handling not supported (For nvptx, there is no effective change, due to other misconfiguration.) PR target/119645 libstdc++-v3/ * acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY) [GCN, nvptx]: Hard-code results. * configure: Regenerate. * configure.host [GCN, nvptx] (atomicity_dir): Set to 'cpu/generic/atomicity_builtins'.
2025-04-05Daily bump.GCC Administrator1-0/+57