aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
AgeCommit message (Collapse)AuthorFilesLines
2023-08-24libstdc++: Tweak some preprocessor conditions for feature testsJonathan Wakely3-18/+18
Update a preprocessor condition using __cplusplus and _GLIBCXX_HOSTED to use the relevant feature test macro for <syncstream>. Also add comments to some conditions saying which C++ standard revision the check corresponds to. libstdc++-v3/ChangeLog: * include/std/atomic: Add comment to #ifdef and fix indentation. * include/std/ostream: Check __glibcxx_syncbuf instead of __cplusplus and _GLIBCXX_HOSTED. * include/std/thread: Add comment to #ifdef.
2023-08-24libstdc++: Implement new SI prefixes in <ratio> for C++23 (P2734R0)Jonathan Wakely4-20/+61
This is a no-op for libstdc++, because our intmax_t is a 64-bit type and so is incapable of representing the largest and smallest ratios from C++11, let alone the new ones. I've added them to the file anyway (and defined the feature test macro) so that if somebody ports libstdc++ to a target with 128-bit intmax_t then they'll be present. libstdc++-v3/ChangeLog: * include/bits/version.def (__cpp_lib_ratio): Define. * include/bits/version.h: Regenerate. * include/std/ratio (quecto, ronto, yocto, zepto) (zetta, yotta, ronna, quetta): Define. * testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Adjust dg-error line numbers.
2023-08-24libstdc++: Add pretty printer for std::localeJonathan Wakely2-0/+81
Print the locale's name, except when it uses the same named C locale for all categories except one, in which case print something like: std::locale = "en_GB.UTF-8" with "LC_CTYPE=en_US.UTF-8" libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdLocalePrinter): New printer class. * testsuite/libstdc++-prettyprinters/locale.cc: New test.
2023-08-24libstdc++: Declutter std::optional and std:variant pretty printers [PR110944]Jonathan Wakely4-23/+22
As the PR says, including the template arguments in the GDB output of these class templates can result in very long names, especially for std::variant. You can use 'whatis' or other GDB commands to get details of the type, we don't need to include it in the value. We could consider including the type if it's not too long, but I think consistency is better (and we already omit the template arguments for std::vector and other class templates). libstdc++-v3/ChangeLog: PR libstdc++/110944 * python/libstdcxx/v6/printers.py (StdExpOptionalPrinter): Do not show template arguments. (StdVariantPrinter): Likewise. * testsuite/libstdc++-prettyprinters/compat.cc: Adjust expected output. * testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise. * testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
2023-08-24Daily bump.GCC Administrator1-0/+19
2023-08-23libstdc++: Fix tests relying on operator new/delete overloadFrançois Dumont10-4/+56
Fix tests that are checking for an expected allocation plan. They are failing if an allocation is taking place outside the test main. libstdc++-v3/ChangeLog * testsuite/util/replacement_memory_operators.h (counter::scope): New, capture and reset counter count at construction and restore it at destruction. (counter::check_new): Add scope instantiation. * testsuite/23_containers/unordered_map/96088.cc (main): Add counter::scope instantiation. * testsuite/23_containers/unordered_multimap/96088.cc (main): Likewise. * testsuite/23_containers/unordered_multiset/96088.cc (main): Likewise. * testsuite/23_containers/unordered_set/96088.cc (main): Likewise. * testsuite/ext/malloc_allocator/deallocate_local.cc (main): Likewise. * testsuite/ext/new_allocator/deallocate_local.cc (main): Likewise. * testsuite/ext/throw_allocator/deallocate_local.cc (main): Likewise. * testsuite/ext/pool_allocator/allocate_chunk.cc (started): New global. (operator new(size_t)): Check started. (main): Set/Unset started. * testsuite/17_intro/no_library_allocation.cc: New test case.
2023-08-22Daily bump.GCC Administrator1-0/+5
2023-08-21libstdc++: Remove reliance on unspecified behaviour in ↵Jonathan Wakely1-3/+11
std::rethrow_if_nested test This test case calls std::set_terminate while there is an active exception. Since LWG 2111 it is unspecified which terminate handler is used when std::nested_exception::rethrow_nested() calls std::terminate. With libsupc++ the global handler changed by std::set_terminate is used, but libc++abi uses the active exception's handler (the one that was current when the exception was first thrown). Adjust the test case so that it works with either implementation choice. So that the process doesn't exit cleanly if std::terminate happens sooner than expected, use a global variable to control when the "clean terminate" behaviour happens. libstdc++-v3/ChangeLog: * testsuite/18_support/nested_exception/rethrow_if_nested-term.cc: Call std::set_terminate before throwing the nested exception.
2023-08-19Daily bump.GCC Administrator1-0/+22
2023-08-18libstdc++: Revert pre-C++23 support for 16-bit float types [PR111060]Jonathan Wakely2-5/+5
In r14-3304-g1a566fddea212a and r14-3305-g6cf214b4fc97f5 I tried to enable std::format for 16-bit float types before C++23. This causes errors for targets where the types are defined but can't actually be used, e.g. i686 without sse2. Make the std::numeric_limits and std::formatter specializations for _Float16 and __bfloat16_t depend on the __STDCPP_FLOAT16_T__ and __STDCPP_BFLOAT16_T__ macros again, so they're only defined for C++23 when the type is fully supported. This is OK because the main point of my earlier commits was to add better support for _Float32 and _Float64. It seems fine for the new 16-bit types to only be supported for C++23, as they were never present before GCC 13 anyway. libstdc++-v3/ChangeLog: PR target/111060 * include/std/format (formatter): Only define specializations for 16-bit floating-point types for C++23. * include/std/limits (numeric_limits): Likewise.
2023-08-18libstdc++: Replace non-type-dependent uses of wchar_t in <format> and <chrono>Jonathan Wakely2-13/+14
This is one more piece of the rework to make wchar_t support in std::format depend on _GLIBCXX_USE_WCHAR_T. In <format> the __to_wstring_numeric function is called with arguments that aren't type-dependent, so a declaration needs to be available, or the calls need to be guarded by _GLIBCXX_USE_WCHAR_T. In <chrono> there is a similarly non-type-dependent call to std::format with a wchar_t format string, which is ill-formed when the wchar_t overloads of std::format are not declared. Use _GLIBCXX_WIDEN to make it type-dependent. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (operator<<): Make uses of wide strings with streams and std::format type-dependent on _CharT. * include/std/format [!_GLIBCXX_USE_WCHAR_T] Do not use __to_wstring_numeric.
2023-08-18libstdc++: Fix incomplete rework of wchar_t support in std::formatJonathan Wakely2-14/+14
r14-3300-g023a62b77f999b left make_wformat_args and some uses of std::wformat_context unguarded by _GLIBCXX_USE_WCHAR_T. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (operator<<): Use __format_context. * include/std/format (__format::__format_context): New alias template. [!_GLIBCXX_USE_WCHAR_T] (wformat_args, make_wformat_arg): Disable.
2023-08-18Daily bump.GCC Administrator1-0/+227
2023-08-18Revert "libstdc++: Reuse double overload of __convert_to_v if possible"Jonathan Wakely1-6/+0
This reverts commit aad83d61d2e92b168688f7b6bd00b8604d11fc9f. libstdc++-v3/ChangeLog: * config/locale/generic/c_locale.cc:
2023-08-17libstdc++: Replace global std::string objects in tzdb.ccJonathan Wakely1-2/+2
When the library is built with --disable-libstdcxx-dual-abi the only type of std::string supported is the COW string, and the two global std::string objects in tzdb.cc have to allocate memory. I added them thinking they would fit in the SSO string buffer, but that's not the case when the library only uses COW strings. Replace them with string_view objects to avoid any allocations. libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (tzdata_file, leaps_file): Change type to std::string_view.
2023-08-17libstdc++: Reuse double overload of __convert_to_v if possibleJonathan Wakely1-0/+6
For targets where double and long double have the same representation we can reuse the same __convert_to_v code for both types. This will slightly reduce the size of the compiled code in the library. libstdc++-v3/ChangeLog: * config/locale/generic/c_locale.cc (__convert_to_v): Reuse double overload for long double if possible.
2023-08-17libstdc++: Micro-optimize construction of named std::localeJonathan Wakely1-16/+23
This shaves about 100ns off the std::locale constructor for named locales (which is only about 1% of the total time). Using !*s instead of !strcmp(s, "") doesn't make any difference as GCC optimizes that already even at -O1. !strcmp(s, "C") is optimized at -O2 so replacing that with s[0] == 'C' && s[1] == '\0' only matters for the --enable-libstdcxx-debug builds. But !strcmp(s, "POSIX") always makes a call to strcmp at any optimization level. We make that strcmp call, maybe several times, for any locale name except for "C" (which will be matched before we get to the check for "POSIX"). For most targets, locale names begin with a lowercase letter and the only one that begins with 'P' is "POSIX". Replacing !strcmp(s, "POSIX") with s[0] == 'P' && !strcmp(s+1, "OSIX") means that we avoid calling strcmp unless the string really does match "POSIX". Maybe more importantly, I find is_C_locale(s) easier to read than strcmp(s, "C") == 0 || strcmp(s, "POSIX") == 0, and !is_C_locale(s) easier to read than strcmp(s, "C") != 0 && strcmp(s, "POSIX") != 0. libstdc++-v3/ChangeLog: * src/c++98/localename.cc (is_C_locale): New function. (locale::locale(const char*)): Use is_C_locale.
2023-08-17libstdc++: Optimize std::string::assign(Iter, Iter) [PR110945]Jonathan Wakely1-4/+38
Calling string::assign(Iter, Iter) with "foreign" iterators (not the string's own iterator or pointer types) currently constructs a temporary string and then calls replace to copy the characters from it. That means we copy from the iterators twice, and if the replace operation has to grow the string then we also allocate twice. By using *this = basic_string(first, last, get_allocator()) we only perform a single allocation+copy and then do a cheap move assignment instead of a second copy (and possible allocation). But that alternative has to be done conditionally, so that we don't pessimize the native iterator case (the string's own iterator and pointer types) which currently select efficient overloads of replace which will not allocate at all if the string already has sufficient capacity. For C++20 we can extend that efficient case to work for any contiguous iterator with the right value type, not just for the string's native iterators. So the change is to inline the code that decides whether to work in place or to allocate+copy (instead of deciding that via overload resolution for replace), and for the allocate+copy case do a move assignment instead of another call to replace. For C++98 there is no change, as we can't do an efficient move assignment anyway, so keep the current code. We can also simplify assign(initializer_list<CharT>) because the backing array for an initializer_list is always disjunct with *this, so most of the code in _M_replace is not needed. libstdc++-v3/ChangeLog: PR libstdc++/110945 * include/bits/basic_string.h (basic_string::assign(Iter, Iter)): Dispatch to _M_replace or move assignment from a temporary, based on the iterator type.
2023-08-17libstdc++: Add std::formatter specializations for extended float typesJonathan Wakely3-35/+236
This makes it possible to format _Float32, _Float64 etc. in C++20 mode. Previously it was only possible to format them in C++23 when the <stdfloat> typedefs and the std::to_chars overloads were defined. Instead of relying on std::to_chars for those types, we can just reuse the formatters for float, double and long double. This also avoids template bloat by reusing the same specializations instead of instantiating __formatter_fp for every different type. libstdc++-v3/ChangeLog: * include/std/format (formatter): Add partial specializations for extended floating-point types. * testsuite/std/format/functions/format.cc: Move test_float128() to ... * testsuite/std/format/formatter/ext_float.cc: New test.
2023-08-17libstdc++: Define std::numeric_limits<_FloatNN> before C++23Jonathan Wakely2-95/+103
The extended floating-point types such as _Float32 are supported by GCC prior to C++23, you just can't use the standard-conforming names from <stdfloat> to refer to them. This change defines the specializations of std::numeric_limits for those types for older dialects, not only for C++23. libstdc++-v3/ChangeLog: * include/bits/c++config (__gnu_cxx::__bfloat16_t): Define whenever __BFLT16_DIG__ is defined, not only for C++23. * include/std/limits (numeric_limits<bfloat16_t>): Likewise. (numeric_limits<_Float16>, numeric_limits<_Float32>) (numeric_limits<_Float64>): Likewise for other extended floating-point types.
2023-08-17libstdc++: Fix -Wunused-parameter in <experimental/internet>Jonathan Wakely1-1/+1
libstdc++-v3/ChangeLog: * include/experimental/internet (address_v4::to_string): Remove unused parameter name.
2023-08-17libstdc++: Make __cmp_cat::__unseq constructor constevalJonathan Wakely2-1/+9
This constructor should only ever be used with a literal 0 as the argument, so we can make it consteval. This has the nice advantage that it is expanded immediately in the front end, and so GDB will never step into the __cmp_cat::__unseq::__unseq(__unseq*) constructor that is uninteresting and probably confusing to users. libstdc++-v3/ChangeLog: * libsupc++/compare (__cmp_cat::__unseq): Make ctor consteval. * testsuite/18_support/comparisons/categories/zero_neg.cc: Prune excess errors caused by invalid consteval calls.
2023-08-17libstdc++: Simplify chrono::__units_suffix using std::formatJonathan Wakely1-55/+29
For std::chrono formatting we can simplify __units_suffix by using std::format_to to generate the "[n/m]s" suffix with the correct character type and write directly to the output iterator, so it doesn't need to be widened using ctype. We can't remove the use of ctype::widen for formatting a time zone abbreviation as a wide string, because that can contain arbitrary characters that can't be widened by __to_wstring_numeric. This also fixes a bug in the chrono formatter for %Z which created a dangling wstring_view. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (__units_suffix_misc): Remove. (__units_suffix): Return a known suffix as string view, do not write unknown suffixes to a buffer. (__fmt_units_suffix): New function that formats the suffix using std::format_to. (operator<<, __chrono_formatter::_M_q): Use __fmt_units_suffix. (__chrono_formatter::_M_Z): Correct lifetime of wstring.
2023-08-17libstdc++: Rework std::format support for wchar_tJonathan Wakely2-36/+82
This changes how std::format creates wide strings, by replacing uses of std::ctype<wchar_t>::widen with the recently-added __to_wstring_numeric helper function. This removes the dependency on the locale, which should only be used for locale-specific formats such as {:Ld}. Also disable all the wide string formatting support if the _GLIBCXX_USE_WCHAR_T macro is not defined. This is consistent with other wchar_t support being disabled if the library is built without that macro defined. libstdc++-v3/ChangeLog: * include/std/format [_GLIBCXX_USE_WCHAR_T]: Guard all wide string formatters with this macro. (__formatter_int::_M_format_int, __formatter_fp::format) (formatter<const void*, C>::format): Use __to_wstring_numeric instead of std::ctype::widen. (__formatter_fp::_M_localize): Use hardcoded wchar_t values instead of std::ctype::widen. * testsuite/std/format/functions/format.cc: Add more checks for wstring formatting of arithmetic types.
2023-08-17libstdc++: Implement std::to_string in terms of std::format (P2587R3)Jonathan Wakely10-12/+429
This change for C++26 affects std::to_string for floating-point arguments, so that they should be formatted using std::format("{}", v) instead of using sprintf. The modified specification in the standard also affects integral arguments, but there's no observable difference for them, and we already use std::to_chars for them anyway. To avoid <string> depending on all of <format>, this change actually just uses std::to_chars directly instead of using std::format. This is equivalent, because the format spec "{}" doesn't use any of the other features of std::format. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (to_string(floating-point-type)): Implement using std::to_chars for C++26. * include/bits/version.def (__cpp_lib_to_string): Define. * include/bits/version.h: Regenerate. * testsuite/21_strings/basic_string/numeric_conversions/char/dr1261.cc: Adjust expected result in C++26 mode. * testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/dr1261.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/to_string_float.cc: New test. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring_float.cc: New test. * testsuite/21_strings/basic_string/numeric_conversions/version.cc: New test.
2023-08-17libstdc++: Optimize std::to_string using std::string::resize_and_overwriteJonathan Wakely2-52/+123
This uses std::string::__resize_and_overwrite to avoid initializing the string buffer with characters that are immediately overwritten. This results in about 6% better performance for the std_to_string case in int-benchmark.cc from https://github.com/fmtlib/format-benchmark This requires a change to a testcase. The previous implementation guaranteed that the string returned from std::to_string(integral-type) would have no excess capacity, because it was constructed with the correct length. The new implementation constructs an empty string and then resizes it with resize_and_overwrite, which over-allocates. This means that the "no-excess capacity" guarantee no longer holds. We can also greatly improve the performance of std::to_wstring by using std::to_string and then widening it with a new helper function, instead of using std::swprintf to do the formatting. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (to_string(integral-type)): Use resize_and_overwrite when available. (__to_wstring_numeric): New helper functions. (to_wstring): Use std::to_string then __to_wstring_numeric. * testsuite/21_strings/basic_string/numeric_conversions/char/to_string_int.cc: Remove check for no excess capacity.
2023-08-17libstdc++: Define std::string::resize_and_overwrite for C++11 and COW stringJonathan Wakely8-59/+214
There are several places in the library where we can improve performance using resize_and_overwrite so it's inconvenient only being able to use it in C++23 mode, and only for cxx11 strings. This adds it for COW strings, and also adds __resize_and_overwrite as an extension for C++11 mode. The new __resize_and_overwrite is available for C++11 and later, so within the library we can use that consistently even in C++23. In order to avoid making a copy (which might not be possible for non-copyable, non-movable types) the callable is passed to resize_and_overwrite as an lvalue reference. Unlike wrapping it in std::ref(op) this ensures that invoking it as std::move(op)(n, p) will use the correct value category. It also avoids any overhead that would be added by wrapping it in a lambda like [&op](auto p, auto n) { return std::move(op)(p, n); }. Adjust std::format to use the new __resize_and_overwrite, which we can assume exists because we only use std::basic_string<char> and std::basic_string<wchar_t>, so no program-defined specializations. The uses in <experimental/internet> cannot be replaced, because those are type-dependent on an Allocator template parameter, which could mean they use program-defined specializations of std::basic_string that don't have the __resize_and_overwrite extension. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (__resize_and_overwrite): New function. * include/bits/basic_string.tcc (__resize_and_overwrite): New function. (resize_and_overwrite): Simplify by using reserve instead of growing the string manually. Adjust for C++11 compatibility. * include/bits/cow_string.h (resize_and_overwrite): New function. (__resize_and_overwrite): New function. * include/bits/version.def (__cpp_lib_string_resize_and_overwrite): Do not depend on cxx11abi. * include/bits/version.h: Regenerate. * include/std/format (__formatter_fp::_S_resize_and_overwrite): Remove. (__formatter_fp::format, __formatter_fp::_M_localize): Use __resize_and_overwrite instead of _S_resize_and_overwrite. * testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc: Adjust for C++11 compatibility when included by ... * testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite_ext.cc: New test.
2023-08-17libstdc++: Implement P2770R0 changes to join_view / join_with_viewPatrick Palka3-49/+257
This C++23 paper fixes an issue in these views when adapting a certain kind of non-forward range, and we treat it as a DR against C++20. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/regex.h (regex_iterator::iterator_concept): Define for C++20 as per P2770R0. (regex_token_iterator::iterator_concept): Likewise. * include/std/ranges (__detail::__as_lvalue): Define. (join_view::_Iterator): Befriend join_view. (join_view::_Iterator::_M_satisfy): Use _M_get_outer instead of _M_outer. (join_view::_Iterator::_M_get_outer): Define. (join_view::_Iterator::_Iterator): Split constructor taking _Parent argument into two as per P2770R0. Remove constraint on default constructor. (join_view::_Iterator::_M_outer): Make this data member present only when the underlying range is forward. (join_view::_Iterator::operator++): Use _M_get_outer instead of _M_outer. (join_view::_Iterator::operator--): Use __as_lvalue helper. (join_view::_Iterator::operator==): Adjust constraints as per P2770R0. (join_view::_Sentinel::__equal): Use _M_get_outer instead of _M_outer. (join_view::_M_outer): New data member when the underlying range is non-forward. (join_view::begin): Adjust definition as per P2770R0. (join_view::end): Likewise. (join_with_view::_M_outer_it): New data member when the underlying range is non-forward. (join_with_view::begin): Adjust definition as per P2770R0. (join_with_view::end): Likewise. (join_with_view::_Iterator::_M_outer_it): Make this data member present only when the underlying range is forward. (join_with_view::_Iterator::_M_get_outer): Define. (join_with_view::_Iterator::_Iterator): Split constructor taking _Parent argument into two as per P2770R0. Remove constraint on default constructor. (join_with_view::_Iterator::_M_update_inner): Adjust definition as per P2770R0. (join_with_view::_Iterator::_M_get_inner): Likewise. (join_with_view::_Iterator::_M_satisfy): Adjust calls to _M_get_inner. Use _M_get_outer instead of _M_outer_it. (join_with_view::_Iterator::operator==): Adjust constraints as per P2770R0. (join_with_view::_Sentinel::operator==): Use _M_get_outer instead of _M_outer_it. * testsuite/std/ranges/adaptors/p2770r0.cc: New test.
2023-08-17libstdc++: Convert _RangeAdaptorClosure into a CRTP base [PR108827]Patrick Palka2-42/+45
Using the CRTP idiom for this base class avoids bloating the size of a pipeline when adding distinct empty range adaptor closure objects to it, as detailed in section 4.1 of P2387R3. But it means we can no longer define its operator| overloads as hidden friends, since it'd mean each instantiation of _RangeAdaptorClosure introduces its own distinct set of hidden friends. So e.g. for the outer | in x | (views::reverse | views::join) ADL would find 6 distinct hidden operator| friends: two from _RangeAdaptorClosure<_Reverse> two from _RangeAdaptorClosure<_Join> two from _RangeAdaptorClosure<_Pipe<_Reverse, _Join>> but we really only want to consider the last two. We avoid this issue by instead defining the operator| overloads at namespace scope alongside _RangeAdaptorClosure. This should be fine because the only types defined in this namespace are _RangeAdaptorClosure, _RangeAdaptor, _Pipe and _Partial, so we don't have to worry about unintentional ADL. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> PR libstdc++/108827 libstdc++-v3/ChangeLog: * include/std/ranges (__adaptor::_RangeAdaptorClosure): Convert into a CRTP class template. Move hidden operator| friends into namespace scope and adjust their constraints. (__closure::__is_range_adaptor_closure_fn): Define. (__closure::__is_range_adaptor_closure): Define. (__adaptor::_Partial): Adjust use of _RangeAdaptorClosure. (__adaptor::_Pipe): Likewise. (views::_All): Likewise. (views::_Join): Likewise. (views::_Common): Likewise. (views::_Reverse): Likewise. (views::_Elements): Likewise. (views::_Adjacent): Likewise. (views::_AsRvalue): Likewise. (views::_Enumerate): Likewise. (views::_AsConst): Likewise. * testsuite/std/ranges/adaptors/all.cc: Reinstate assertion expecting that adding empty range adaptor closure objects to a pipeline doesn't increase the size of a pipeline.
2023-08-17libstdc++: Fix std::format("{:F}", inf) to use uppercaseJonathan Wakely2-2/+20
std::format was treating {:f} and {:F} identically on the basis that for the fixed 1.234567 format there are no alphabetical characters that need to be in uppercase. But that's wrong for infinities and NaNs, which should be formatted as "INF" and "NAN" for {:F}. libstdc++-v3/ChangeLog: * include/std/format (__format::_Pres_type): Add _Pres_F. (__formatter_fp::parse): Use _Pres_F for 'F'. (__formatter_fp::format): Set __upper for _Pres_F. * testsuite/std/format/functions/format.cc: Check formatting of infinity and NaN for each presentation type.
2023-08-17libstdc++: Regenerate Makefile.inJonathan Wakely1-3/+3
libstdc++-v3/ChangeLog: * include/Makefile.in: Regenerate.
2023-08-17libstdc++: Disable PCH for tests that rely on include orderJonathan Wakely3-0/+3
These tests expect to be able to #undef a feature test macro and then include <version> to get it redefined. But if <version> has already been included by the <bits/stdc++.h> PCH then including it again does nothing and the macro remains undefined. libstdc++-v3/ChangeLog: * testsuite/24_iterators/move_iterator/p2520r0.cc: Add no_pch. * testsuite/std/format/functions/format.cc: Likewise. * testsuite/std/format/functions/format_c++23.cc: Likewise.
2023-08-17libstdc++: Fix testsuite no_pch directiveJonathan Wakely1-1/+3
The { dg-add-options no_pch } directive is supposed to add a macro definition that invalidates the PCH file, and ensures that the #include directives in the test file are processed as written. But the proc that adds the options actually removes all existing options, cancelling out any previous dg-options directive. This means that using no_pch will cause FAILs in a file that relies on other options set by an earlier dg-options. The no_pch directive was added for PR libstdc++/21769 where Janis suggested adding it as return "$flags -D__GLIBCXX__=99999999" but what was actually committed didn't include the $flags so replaced them. Additionally, using no_pch only prevents the precompiled version of <bits/stdc++.h> from being included, it doesn't prevent the non-precompiled version being included by -include bits/stdc++.h in the test flags. Use regsub to filter that out of the options as well. libstdc++-v3/ChangeLog: * testsuite/lib/dg-options.exp (add_options_for_no_pch): Remove any "-include bits/stdc++.h" from options and add the macro to the existing options instead of replacing them.
2023-08-17Daily bump.GCC Administrator1-0/+447
2023-08-16libstdc++: Fix std::basic_string::resize_and_overwriteJonathan Wakely4-3/+34
The callable used for resize_and_overwrite was being passed the string's expanded capacity, which might be greater than the new size being requested. This is not conforming, as the standard requires the same n to be passed to the callable that the user passed to resize_and_overwrite. The existing tests didn't catch this because they all used a value which was more than twice the existing capacity, so the _M_create call allocated exactly what was requested, and the value passed to the callable was correct. But when the requested size is greater than the current capacity but smaller than twice the current capacity, _M_create will allocate twice the current capacity and then that value was being passed to the callable. I noticed this because std::format(L"{}", 0.25) was producing L"0.25XX" where the XX characters were whatever happened to be on the stack before the call. When std::format used resize_and_overwrite to widen a string it was copying too many characters into the destination and setting the result's length too long. I've added a test for this case, and a new test that doesn't hardcode -std=gnu++20 so can be used to test std::format in C++23 and C++26 modes. libstdc++-v3/ChangeLog: * include/bits/basic_string.tcc (resize_and_overwrite): Invoke the callable with the same size as resize_and_overwrite was called with. * testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc: Check with small values for the new size. * testsuite/std/format/functions/format.cc: Check wide formatting of double values that produce small strings. * testsuite/std/format/functions/format_c++23.cc: New test.
2023-08-16libstdc++: Update __cplusplus value for C++23 in version.defJonathan Wakely2-37/+37
libstdc++-v3/ChangeLog: * include/bits/version.def (stds): Update value for C++23. * include/bits/version.h: Regenerate.
2023-08-16libstdc++: Fix comment naming upstream PSTL test fileJonathan Wakely5-5/+5
These tests were derived from set.pass.cpp not set.pass.cc, specifically pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp in the LLVM repo. libstdc++-v3/ChangeLog: * testsuite/25_algorithms/pstl/alg_sorting/set_difference.cc: Fix name of upstream file this was derived from. * testsuite/25_algorithms/pstl/alg_sorting/set_intersection.cc: Likewise. * testsuite/25_algorithms/pstl/alg_sorting/set_symmetric_difference.cc: Likewise. * testsuite/25_algorithms/pstl/alg_sorting/set_union.cc: Likewise. * testsuite/25_algorithms/pstl/alg_sorting/set_util.h: Likewise.
2023-08-16libstdc++: Replace all manual FTM definitions and useArsen Arsenović95-724/+703
libstdc++-v3/ChangeLog: * libsupc++/typeinfo: Switch to bits/version.h for __cpp_lib_constexpr_typeinfo. * libsupc++/new: Switch to bits/version.h for __cpp_lib_{launder,hardware_interference_size,destroying_delete}. (launder): Guard behind __cpp_lib_launder. (hardware_destructive_interference_size) (hardware_constructive_interference_size): Guard behind __cpp_lib_hardware_interference_size. * libsupc++/exception: Switch to bits/version.h for __cpp_lib_uncaught_exceptions. (uncaught_exceptions): Guard behind __cpp_lib_uncaught_exceptions. * libsupc++/compare: Switch to bits/version.h for __cpp_lib_three_way_comparison. (three_way_comparable, three_way_comparable_with) (compare_three_way, weak_order, strong_order, partial_order): Guard behind __cpp_lib_three_way_comparison >= 201907L. * include/std/chrono: Drop __cpp_lib_chrono definition. * include/std/vector: Switch to bits/version.h for __cpp_lib_erase_if. (erase, erase_if): Guard behind __cpp_lib_erase_if. * include/std/variant: Switch to bits/version.h for __cpp_lib_variant. Guard whole header behind that FTM. * include/std/utility: Switch to bits/version.h for __cpp_lib_{exchange_function,constexpr_algorithms,as_const}, __cpp_lib_{integer_comparison_functions,to_underlying}, and __cpp_lib_unreachable. (exchange): Guard behind __cpp_lib_exchange_function. (cmp_equal, cmp_not_equal, cmp_less, cmp_greater, cmp_less_equal) (cmp_greater_equal, in_range): Guard behind __cpp_lib_integer_comparison_functions. (to_underlying): Guard behind __cpp_lib_to_underlying. (unreachable): Guard behind __cpp_lib_unreachable. * include/std/type_traits: Switch to bits/version.h for __cpp_lib_is_{null_pointer,final,nothrow_convertible,aggregate}, __cpp_lib_is_{constant_evaluated,invocable,layout_compatible}, __cpp_lib_is_{pointer_interconvertible,scoped_enum,swappable}, __cpp_lib_{logical_traits,reference_from_temporary,remove_cvref}, __cpp_lib_{result_of_sfinae,transformation_trait_aliases}, __cpp_lib_{type_identity,type_trait_variable_templates}, __cpp_lib_{unwrap_ref,void_t,integral_constant_callable}, __cpp_lib_{bool_constant,bounded_array_traits}, and __cpp_lib_has_unique_object_representations. (integral_constant::operator()): Guard behind __cpp_lib_integral_constant_callable. (bool_constant): Guard behind __cpp_lib_bool_constant. (conjunction, disjunction, negation, conjunction_v, disjunction_v) (negation_v): Guard behind __cpp_lib_logical_traits. (is_null_pointer): Guard behind __cpp_lib_is_null_pointer. (is_final): Guard behind __cpp_lib_is_final. (is_nothrow_convertible, is_nothrow_convertible_v): Guard behind __cpp_lib_is_nothrow_convertible. (remove_const_t, remove_volatile_t, remove_cv_t) (add_const_t, add_volatile_t, add_cv_t): Guard behind __cpp_lib_transformation_trait_aliases. (void_t): Guard behind __cpp_lib_void_t. (is_swappable_with_v, is_nothrow_swappable_with_v) (is_swappable_with, is_nothrow_swappable_with): Guard behind __cpp_lib_is_swappable. (is_nothrow_invocable_r, is_invocable_r, invoke_result) (is_invocable, invoke_result_t): Guard behind __cpp_lib_is_invocable. (alignment_of_v, extent_v, has_virtual_destructor_v) (is_abstract_v, is_arithmetic_v, is_array_v) (is_assignable_v, is_base_of_v, is_class_v, is_compound_v) (is_constructible_v, is_const_v, is_convertible_v) (is_copy_assignable_v, is_copy_constructible_v) (is_default_constructible_v, is_destructible_v) (is_empty_v, is_enum_v, is_final_v, is_floating_point_v) (is_function_v, is_fundamental_v, is_integral_v) (is_invocable_r_v, is_invocable_v, is_literal_type_v) (is_lvalue_reference_v, is_member_function_pointer_v) (is_member_object_pointer_v, is_member_pointer_v) (is_move_assignable_v, is_move_constructible_v) (is_nothrow_assignable_v, is_nothrow_constructible_v) (is_nothrow_copy_assignable_v, is_nothrow_copy_constructible_v) (is_nothrow_default_constructible_v, is_nothrow_destructible_v) (is_nothrow_invocable_r_v, is_nothrow_invocable_v) (is_nothrow_move_assignable_v, is_nothrow_move_constructible_v) (is_null_pointer_v, is_object_v, is_pod_v, is_pointer_v) (is_polymorphic_v, is_reference_v, is_rvalue_reference_v) (is_same_v, is_scalar_v, is_signed_v, is_standard_layout_v) (is_trivially_assignable_v, is_trivially_constructible_v) (is_trivially_copyable_v, is_trivially_copy_assignable_v) (is_trivially_copy_constructible_v) (is_trivially_default_constructible_v) (is_trivially_destructible_v, is_trivially_move_assignable_v) (is_trivially_move_constructible_v, is_trivial_v, is_union_v) (is_unsigned_v, is_void_v, is_volatile_v, rank_v, as variadic): Guard behind __cpp_lib_type_trait_variable_templates. (has_unique_object_representations) (has_unique_object_representations_v): Guard behind __cpp_lib_has_unique_object_representation. (is_aggregate): Guard behind __cpp_lib_is_aggregate. (remove_cvref, remove_cvref_t): Guard behind __cpp_lib_remove_cvref. (type_identity, type_identity_t): Guard behind __cpp_lib_type_identity. (unwrap_reference, unwrap_reference_t, unwrap_ref_decay) (unwrap_ref_decay_t): Guard behind __cpp_lib_unwrap_ref. (is_bounded_array_v, is_unbounded_array_v, is_bounded_array) (is_unbounded_array): Guard behind __cpp_lib_bounded_array_traits. (is_scoped_enum, is_scoped_enum_v): Guard behind __cpp_lib_is_scoped_enum. (reference_constructs_from_temporary) (reference_constructs_from_temporary_v): Guard behind __cpp_lib_reference_from_temporary. * include/std/tuple: Switch to bits/version.h for __cpp_lib_{constexpr_tuple,tuple_by_type,apply_make_from_tuple}. (get<T>): Guard behind __cpp_lib_tuple_by_type. (apply): Guard behind __cpp_lib_apply. (make_from_tuple): Guard behind __cpp_lib_make_from_tuple. * include/std/syncstream: Switch to bits/version.h for __cpp_lib_syncbuf. Guard header behind that FTM. * include/std/string_view: Switch to bits/version.h for __cpp_lib_{string_{view,contains},constexpr_string_view} and __cpp_lib_starts_ends_with. (basic_string_view::starts_with, basic_string_view::ends_with): Guard behind __cpp_lib_starts_ends_with. [C++23 && _GLIBCXX_HOSTED && !defined(__cpp_lib_string_contains)]: Assert as impossible ithout a bug in C++23. * include/std/string: Switch to bits/version.h for __cpp_lib_erase_if. (erase, erase_if): Guard behind __cpp_lib_erase_if. * include/std/thread: Switch to bits/version.h for __cpp_lib_jthread. * include/std/stop_token: Switch to bits/version.h for __cpp_lib_jthread. * include/std/spanstream: Switch to bits/version.h for __cpp_lib_spanstream. Guard header behind that FTM. * include/std/span: Switch to bits/version.h for __cpp_lib_span. Guard header behind that FTM. * include/std/source_location: Switch to bits/version.h for __cpp_lib_source_location. Guard header with that FTM. * include/std/shared_mutex: Switch to bits/version.h for __cpp_lib_shared{,_timed}_mutex. (shared_mutex): Guard behind __cpp_lib_shared_mutex. * include/std/semaphore: Switch to bits/version.h for __cpp_lib_semaphore. Guard header behind that FTM. * include/std/ranges: Switch to bits/version.h for __cpp_lib_ranges_{zip,chunk{,_by},slide,join_with}, __cpp_lib_ranges_{repeat_stride,cartesian_product,as_rvalue}, and __cpp_lib_ranges_{as_const,enumerate,iota}. (ranges::zip et al, ranges::chunk et al, ranges::slide et al) (ranges::chunk_by et al, ranges::join_with et al) (ranges::stride et al, ranges::cartesian_product et al) (ranges::as_rvalue et al, ranges::as_const et al) (ranges::enumerate et al): Guard behind appropriate FTM. * include/std/optional: Switch to bits/version.h for __cpp_lib_optional. Guard header behind that FTM. * include/std/numeric: Switch to bits/version.h for __cpp_lib_{gcd{,_lcm},lcm,constexpr_numeric,interpolate} and __cpp_lib_parallel_algorithm. (gcd, lcm): Guard behind __cpp_lib_gcd_lcm. (midpoint): Guard behind __cpp_lib_interpolate. * include/std/numbers: Switch to bits/version.h for __cpp_lib_math_constants. Guard header behind that FTM. * include/std/mutex: Switch to bits/version.h for __cpp_lib_scoped_lock. (scoped_Lock): Guard behind __cpp_lib_scoped_lock. * include/std/memory_resource: Switch to bits/version.h for __cpp_lib_{polymorphic_allocator,memory_resource}. (synchronized_pool_resource): Guard behind __cpp_lib_memory_resource >= 201603L. (polymorphic_allocator): Guard behind __cpp_lib_polymorphic_allocator. * include/std/memory: Switch to bits/version.h for __cpp_lib_{parallel_algorithm,atomic_value_initialization}. * include/std/list: Switch to bits/version.h for __cpp_lib_erase_if. (erase, erase_if): Guard behind __cpp_lib_erase_if. * include/std/latch: Switch to bits/version.h for __cpp_lib_latch. Guard header behind that FTM. * include/std/iterator: Switch to bits/version.h for __cpp_lib_null_iterators. * include/std/iomanip: Switch to bits/version.h for __cpp_lib_quoted_string_io. (quoted): Guard behind __cpp_lib_quoted_string_io. * include/std/functional: Switch to bits/version.h for __cpp_lib_{invoke{,_r},constexpr_functional,bind_front} and __cpp_lib_{not_fn,booyer_moore_searcher}. (invoke): Guard behind __cpp_lib_invoke. (invoke_r): Guard behind __cpp_lib_invoke_r. (bind_front): Guard behind __cpp_lib_bind_front. (not_fn): Guard behind __cpp_lib_not_fn. (boyer_moore_searcher, boyer_moore_horspool_searcher): Guard definition behind __cpp_lib_boyer_moore_searcher. * include/std/forward_list: Switch to bits/version.h for __cpp_lib_erase_if. (erase, erase_if): Guard behind __cpp_lib_erase_if. * include/std/format: Switch to bits/version.h for __cpp_lib_format. Guard header behind that FTM. * include/std/filesystem: Switch to bits/version.h for __cpp_lib_filesystem. Guard header behind that FTM. * include/std/expected: Switch to bits/version.h for __cpp_lib_expected. Guard header behind it. * include/std/execution: Switch to bits/version.h for __cpp_lib_{execution,parallel_algorithm}. Guard header behind either. * include/std/deque: Switch to bits/version.h for __cpp_lib_erase_if. (erase, erase_if): Guard behind __cpp_lib_erase_if. * include/std/coroutine: Switch to bits/version.h for __cpp_lib_coroutine. Guard header behind that FTM. * include/std/concepts: Switch to bits/version.h for __cpp_lib_concepts. Guard header behind that FTM. * include/std/complex: Switch to bits/version.h for __cpp_lib_{complex_udls,constexpr_complex}. (operator""if, operator""i, operator""il): Guard behind __cpp_lib_complex_udls. * include/std/charconv: Swtich to bits/version.h for __cpp_lib_{to_chars,constexpr_charconv}. * include/std/bitset: Switch to bits/version.h for __cpp_lib_constexpr_bitset. * include/std/bit: Switch to bits/version.h for __cpp_lib_{bit_cast,byteswap,bitops,int_pow2,endian}. (bit_cast): Guard behind __cpp_lib_bit_cast. (byteswap): Guard behind __cpp_lib_byteswap. (rotl, rotr, countl_zero, countl_one, countr_zero, countr_one) (popcount): Guard behind __cpp_lib_bitops. (has_single_bit, bit_ceil, bit_floor, bit_width): Guard behind __cpp_lib_int_pow2. (endian): Guard behind __cpp_lib_endian. * include/std/barrier: Switch to bits/version.h for __cpp_lib_barrier. Guard header behind that FTM. * include/std/atomic: Switch to bits/version.h for __cpp_lib_atomic_{is_always_lock_free,float,ref} and __cpp_lib_lock_free_type_aliases. (*::is_always_lock_free): Guard behind __cpp_lib_atomic_is_always_lock_free. (atomic<float>): Guard behind __cpp_lib_atomic_float. (atomic_ref): Guard behind __cpp_lib_atomic_ref. (atomic_signed_lock_free, atomic_unsigned_lock_free): Guard behind __cpp_lib_atomic_lock_free_type_aliases. * include/std/array: Switch to bits/version.h for __cpp_lib_to_array. (to_array): Guard behind __cpp_lib_to_array. * include/std/any: Switch to bits/version.h for __cpp_lib_any. Guard header behind that FTM. * include/std/algorithm: Switch to bits/version.h for __cpp_lib_parallel_algorithm. * include/c_global/cstddef: Switch to bits/version.h for __cpp_lib_byte. (byte): Guard behind __cpp_lib_byte. * include/c_global/cmath: Switch to bits/version.h for __cpp_lib_{hypot,interpolate}. (hypot3): Guard behind __cpp_lib_hypot. (lerp): Guard behind __cpp_lib_interpolate. * include/c_compatibility/stdatomic.h: Switch to bits/stl_version.h for __cpp_lib_atomic. Guard header behind that FTM. * include/bits/utility.h: Switch to bits/version.h for __cpp_lib_{tuple_element_t,integer_sequence,ranges_zip}. (tuple_element_t): Guard behind __cpp_lib_tuple_element_t. (integer_sequence et al): Guard behind __cpp_lib_integer_sequence. * include/bits/uses_allocator_args.h: Switch to bits/version.h for __cpp_lib_make_obj_using_allocator. Guard header behind that FTM. * include/bits/unordered_map.h: Switch to bits/version.h for __cpp_lib_unordered_map_try_emplace. (try_emplace): Guard behind __cpp_lib_unordered_map_try_emplace. * include/bits/unique_ptr.h: Switch to bits/version.h for __cpp_lib_{constexpr_memory,make_unique}. (make_unique): Guard behind __cpp_lib_make_unique. * include/bits/stl_vector.h: Switch to bits/version.h for __cpp_lib_constexpr_vector. * include/bits/stl_uninitialized.h: Switch to bits/version.h for __cpp_lib_raw_memory_algorithms. (uninitialized_default_construct) (uninitialized_default_construct_n, uninitialized_move) (uninitialized_move_n, uninitialized_value_construct) (uninitialized_value_construct_n): Guard behind __cpp_lib_raw_memory_algorithms. * include/bits/stl_tree.h: Switch to bits/version.h for __cpp_lib_generic_associative_lookup. * include/bits/stl_stack.h: Switch to bits/version.h for __cpp_lib_adaptor_iterator_pair_constructor. (stack): Guard iterator-pair constructor behind __cpp_lib_adaptor_iterator_pair_constructor. * include/bits/stl_queue.h: Switch to bits/version.h for __cpp_lib_adaptor_iterator_pair_constructor. (queue): Guard iterator-pair constructor behind __cpp_lib_adaptor_iterator_pair_constructor. * include/bits/stl_pair.h: Switch to bits/version.h for __cpp_lib_{concepts,tuples_by_type}. (get): Guard type-getting overloads behind __cpp_lib_tuples_by_type. * include/bits/stl_map.h: Switch to bits/version.h for __cpp_lib_map_try_emplace. (map<>::try_emplace): Guard behind __cpp_lib_map_try_emplace. * include/bits/stl_list.h: Switch to bits/version.h for __cpp_lib_list_remove_return_type. (__remove_return_type, _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG) [C++20]: guard behind __cpp_lib_list_remove_return_type instead. * include/bits/stl_iterator.h: Switch to bits/version.h for __cpp_lib_{constexpr_iterator,array_constexpr} and __cpp_lib_{make_reverse_iterator,move_iterator_concept}. (make_reverse_iterator): Guard behind __cpp_lib_make_reverse_iterator. (iterator_concept et al): Guard __cpp_lib_move_iterator_concept changes behind that FTM. * include/bits/stl_function.h: Switch to bits/version.h for __cpp_lib_transparent_operators. (equal_to, not_equal_to, greater, less, greater_equal) (less_equal, bit_and, bit_or, bit_xor, bit_not, logical_and) (logical_or, logical_not, plus, minus, multiplies, divides) (modulus, negate): Guard '= void' fwdecls behind __cpp_lib_transparent_operators. (plus<void>, minus<void>, multiplies<void>, divides<void>) (modulus<void>, negate<void>, logical_and<void>, logical_or<void>) (logical_not<void>, bit_and<void>, bit_or<void>, bit_xor<void>) (equal_to<void>, not_equal_to<void>, greater<void>, less<void>) (greater_equal<void>, less_equal<void>, bit_not<void>) (__has_is_transparent): Guard behind __cpp_lib_transparent_operators. * include/bits/stl_algobase.h: Switch to bits/version.h for __cpp_lib_robust_nonmodifying_seq_ops. (robust equal, mismatch): Guard behind __cpp_lib_nonmember_container_access. * include/bits/stl_algo.h: Swtich to bits/version.h for __cpp_lib_{clamp,sample}. (clamp): Guard behind __cpp_lib_clamp. (sample): Guard behind __cpp_lib_sample. * include/bits/specfun.h: Switch to bits/version.h for __cpp_lib_math_special_functions and __STDCPP_MATH_SPEC_FUNCS__. * include/bits/shared_ptr_base.h: Switch to bits/version.h for __cpp_lib_{smart_ptr_for_overwrite,shared_ptr_arrays}. (_Sp_overwrite_tag): Guard behind __cpp_lib_smart_ptr_for_overwrite. * include/bits/shared_ptr_atomic.h: Switch to bits/version.h for __cpp_lib_atomic_shared_ptr. * include/bits/shared_ptr.h: Switch to bits/version.h for __cpp_lib_{enable_shared_from_this,shared_ptr_weak_type}. (shared_ptr<T>::weak_type): Guard behind __cpp_lib_shared_ptr_weak_type. (enable_shared_from_this<T>::weak_from_this): Guard behind __cpp_lib_enable_shared_from_this. * include/bits/ranges_cmp.h: Switch to bits/version.h for __cpp_lib_ranges. * include/bits/ranges_algo.h: Switch to bits/version.h for __cpp_lib_{shift,ranges_{contains,find_last,fold,iota}}. * include/bits/range_access.h: Switch to bits/version.h for __cpp_lib_nonmember_container_access (size, empty, data): Guard behind __cpp_lib_nonmember_container_access. (ssize): Guard behind __cpp_lib_ssize. * include/bits/ptr_traits.h: Switch to bits/version.h. for __cpp_lib_{constexpr_memory,to_address}. (to_address): Guard behind __cpp_lib_to_address. * include/bits/node_handle.h: Switch to bits/version.h for __cpp_lib_node_extract. Guard header behind that FTM. * include/bits/move_only_function.h: Switch to bits/version.h for __cpp_lib_move_only_function. Guard header behind that FTM. * include/bits/move.h: Switch to bits/version.h for __cpp_lib_addressof_constexpr. * include/bits/ios_base.h: Switch to bits/version.h for __cpp_lib_ios_noreplace. (noreplace): Guard with __cpp_lib_ios_noreplace. * include/bits/hashtable.h: Switch to bits/version.h for __cpp_lib_generic_unordered_lookup. (_M_equal_range_tr, _M_count_tr, _M_find_tr): Guard behind __cpp_lib_generic_unordered_lookup. * include/bits/forward_list.h: Switch to bits/version.h for __cpp_lib_list_remove_return_type. (__remove_return_type): Guard behind __cpp_lib_list_remove_return_type. * include/bits/erase_if.h: Switch to bits/version.h for __cpp_lib_erase_if. * include/bits/cow_string.h: Switch to bits/version.h for __cpp_lib_constexpr_string. * include/bits/chrono.h: Swtich to bits/version.h for __cpp_lib_chrono{,_udls}. (ceil): Guard behind __cpp_lib_chrono. (operator""ns et al): Guard behind __cpp_lib_chrono_udls. * include/bits/char_traits.h: Switch to bits/version.h for __cpp_lib_constexpr_char_traits. * include/bits/basic_string.h: Switch to bits/version.h for __cpp_lib_{constexpr_string,string_{resize_and_overwrite,udls}}. (resize_and_overwrite): Guard behind __cpp_lib_string_resize_and_overwrite. (operator""s): Guard behind __cpp_lib_string_udls. * include/bits/atomic_wait.h: Switch to bits/version.h for __cpp_lib_atomic_wait. Guard header behind that FTM. * include/bits/atomic_base.h: Switch to bits/version.h for __cpp_lib_atomic_value_initialization and __cpp_lib_atomic_flag_test. (atomic_flag::test): Guard behind __cpp_lib_atomic_flag_test, rather than C++20. * include/bits/allocator.h: Switch to bits/version.h for __cpp_lib_incomplete_container_elements. * include/bits/alloc_traits.h: Switch to using bits/version.h for __cpp_lib_constexpr_dynamic_alloc and __cpp_lib_allocator_traits_is_always_equal. * include/bits/align.h: Switch to bits/version.h for defining __cpp_lib_assume_aligned. (assume_aligned): Guard with __cpp_lib_assume_aligned. * include/bits/algorithmfwd.h: Switch to bits/version.h for defining __cpp_lib_constexpr_algorithms. * include/std/stacktrace: Switch to bits/version.h for __cpp_lib_stacktrace. Guard header behind that FTM. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Update line numbers.
2023-08-16libstdc++: Implement more maintainable <version> headerArsen Arsenović6-349/+3770
This commit replaces the ad-hoc logic in <version> with an AutoGen database that (mostly) declaratively generates a version.h bit which combines all of the FTM logic across all headers together. This generated header defines macros of the form __glibcxx_foo, equivalent to their __cpp_lib_foo variants, according to rules specified in version.def and, optionally, if __glibcxx_want_foo or __glibcxx_want_all are defined, also defines __cpp_lib_foo forms with the same definition. libstdc++-v3/ChangeLog: * include/Makefile.am (bits_freestanding): Add version.h. (allcreated): Add version.h. (${bits_srcdir}/version.h): New rule. Regenerates version.h out of version.{def,tpl}. * include/Makefile.in: Regenerate. * include/bits/version.def: New file. Declares a list of all feature test macros, their values and their preconditions. * include/bits/version.tpl: New file. Turns version.def into a sequence of #if blocks. * include/bits/version.h: New file. Generated from version.def. * include/std/version: Replace with a __glibcxx_want_all define and bits/version.h include.
2023-08-15Daily bump.GCC Administrator1-0/+6
2023-08-14libstdc++: Avoid problematic use of log10 in std::format [PR110860]Paul Dreik1-7/+16
If abs(__v) is smaller than one, the result will be of the form 0.xxxxx. It is only if the magnitude is large that more digits are needed before the decimal dot. This uses frexp instead of log10 which should be less expensive and have sufficient precision for the desired purpose. It removes the problematic cases where log10 will be negative or not fit in an int. Signed-off-by: Paul Dreik <gccpatches@pauldreik.se> libstdc++-v3/ChangeLog: PR libstdc++/110860 * include/std/format (__formatter_fp::format): Use frexp instead of log10.
2023-08-13Daily bump.GCC Administrator1-0/+7
2023-08-11libstdc++: Use __bool_constant entirelyKen Matsui1-7/+7
This patch uses __bool_constant entirely instead of integral_constant<bool> in the type_traits header, specifically for true_type, false_type, and bool_constant. libstdc++-v3/ChangeLog: * include/std/type_traits (true_type): Use __bool_constant instead. (false_type): Likewise. (bool_constant): Likewise. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-08-12Daily bump.GCC Administrator1-0/+60
2023-08-11libstdc++: Fix std::format_to_n return value [PR110990]Jonathan Wakely2-16/+38
When writing to a contiguous iterator, std::format_to_n(out, n, ...) always returns out + n, even if it wrote fewer than n characters to the iterator. The problem is in the _M_finish() member function of the _Iter_sink specialization for contiguous iterators. _M_finish() calls _M_overflow() to update its count of characters written, so it can return the count of characters that would be written if there was room. But _M_overflow() assumes it's only called when the buffer is full, and so switches to the internal buffer. _M_finish() then thinks that if the internal buffer is in use, we already wrote at least n characters and so returns out+n as the output position. We can fix the problem by adding a check in _M_overflow() so that we don't update the count and switch to the internal buffer unless we've run out of room, i.e. _M_unused().size() is zero. The caller then needs to be prepared for _M_count not being the final total, and so add _M_used.size() to it. However, there's not actually any need for _M_finish() to call _M_overflow() to get the count. We now need to use _M_count and _M_used.size() to get the total anyway so _M_overflow() doesn't help with that. And we don't need to use _M_overflow() to flush unwritten characters to the output, because the specialization for contiguous iterators always writes directly to the output without buffering (except when we've exceeded the maximum number of characters, in which case we want to discard the buffered characters anyway). So _M_finish() can be simplified and can avoid calling _M_overflow(). This change also fixes some member functions of other sink classes to only call _M_overflow() when there are characters in the buffer, which is needed to meet _M_overflow's precondition that _M_used().size()!=0. libstdc++-v3/ChangeLog: PR libstdc++/110990 * include/std/format (_Seq_sink::get): Only call _M_overflow if its precondition is met. (_Iter_sink::_M_finish): Likewise. (_Iter_sink<C, ContigIter>::_M_overflow): Only switch to the internal buffer after running out of space. (_Iter_sink<C, ContigIter>::_M_finish): Do not use _M_overflow. (_Counting_sink::count): Likewise. * testsuite/std/format/functions/format_to_n.cc: Check cases where the output fits into the buffer.
2023-08-11libstdc++: Implement C++20 std::chrono::parse [PR104167]Jonathan Wakely20-42/+2816
This adds the missing C++20 features to <chrono>. I've implemented my proposed resolutions to LWG issues 3960, 3961, and 3962. There are some unimplemented flags such as %OI which I think are not implementable in general. It might be possible to use na_llanginfo with ALT_DIGITS, but that isn't available on all targets. I intend to file another LWG issue about that. libstdc++-v3/ChangeLog: PR libstdc++/104167 * include/bits/chrono_io.h (operator|=, operator|): Add noexcept to _ChronoParts operators. (from_stream, parse): Define new functions. (__detail::_Parse, __detail::_Parser): New class templates. * include/std/chrono (__cpp_lib_chrono): Define to 201907L for C++20. * include/std/version (__cpp_lib_chrono): Likewise. * testsuite/20_util/duration/arithmetic/constexpr_c++17.cc: Adjust expected value of feature test macro. * testsuite/20_util/duration/io.cc: Test parsing. * testsuite/std/time/clock/file/io.cc: Likewise. * testsuite/std/time/clock/gps/io.cc: Likewise. * testsuite/std/time/clock/system/io.cc: Likewise. * testsuite/std/time/clock/tai/io.cc: Likewise. * testsuite/std/time/clock/utc/io.cc: Likewise. * testsuite/std/time/day/io.cc: Likewise. * testsuite/std/time/month/io.cc: Likewise. * testsuite/std/time/month_day/io.cc: Likewise. * testsuite/std/time/weekday/io.cc: Likewise. * testsuite/std/time/year/io.cc: Likewise. * testsuite/std/time/year_month/io.cc: Likewise. * testsuite/std/time/year_month_day/io.cc: Likewise. * testsuite/std/time/syn_c++20.cc: Check value of macro and for the existence of parse and from_stream in namespace chrono. * testsuite/std/time/clock/local/io.cc: New test. * testsuite/std/time/parse.cc: New test.
2023-08-11libstdc++: Do not call log10(0.0) in std::format [PR110860]Jonathan Wakely1-1/+1
Calling log10(0.0) returns -inf which has undefined behaviour when converted to an integer. We only need to use log10 for large values anyway. If the value is zero then the larger buffer is only needed due to a large precision, so we don't need to use log10 to estimate the number of digits for the significand. libstdc++-v3/ChangeLog: PR libstdc++/110860 * include/std/format (__formatter_fp::format): Do not call log10 with zero values.
2023-08-11libstdc++: Handle invalid values in std::chrono pretty printersJonathan Wakely2-1/+13
This avoids an IndexError exception when printing invalid chrono::month or chrono::weekday values. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdChronoCalendarPrinter): Check for out-of-range month an weekday indices. * testsuite/libstdc++-prettyprinters/chrono.cc: Check invalid month and weekday values.
2023-08-11libstdc++: Revert accidentally committed change to bits/stl_iterator.hJonathan Wakely1-6/+4
In commit r14-3134-g9cb2a7c8d54b1f I only meant to change some uses of __clamp_iter_cat to use __iter_category_t, I didn't mean to commit the additional change introducing __clamped_iter_cat_t. This reverts that part. libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (__clamped_iter_cat_t): Remove.
2023-08-11Daily bump.GCC Administrator1-0/+27