diff options
Diffstat (limited to 'libstdc++-v3')
46 files changed, 1187 insertions, 545 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 28df8b8..f0b1256 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,203 @@ +2025-04-03 Thomas Schwinge <tschwinge@baylibre.com> + + * config/cpu/nvptx/t-nvptx: Remove. + * configure.host [nvptx]: Adjust. + +2025-04-03 Thomas Schwinge <tschwinge@baylibre.com> + + PR target/119573 + * config/cpu/nvptx/t-nvptx (AM_MAKEFLAGS): Don't amend. + +2025-04-03 Tomasz Kamiński <tkaminsk@redhat.com> + + * testsuite/std/format/functions/format.cc: Restored line. + +2025-04-03 Tomasz Kamiński <tkaminsk@redhat.com> + + PR libstdc++/119593 + * include/bits/unicode.h + (__unicode::__literal_encoding_is_unicode<_CharT>): + Corrected handing for UTF-16 and UTF-32 with "LE" or "BE" suffix. + * include/std/format (__formatter_str::_S_character_width): + Define. + (__formatter_str::_S_character_width): Updated passed char + length. + * testsuite/std/format/functions/format.cc: Test for wchar_t. + +2025-04-02 John David Anglin <danglin@gcc.gnu.org> + + * config/os/hpux/os_defines.h: Only use long long when + __cplusplus >= 201103L. + +2025-04-02 Iain Sandoe <iain@sandoe.co.uk> + + * testsuite/lib/prune.exp: Prune ld warning about duplicatei + rpaths. + +2025-04-01 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/114945 + * include/bits/vector.tcc (vector::_M_default_append): Add + unreachable condition so the compiler knows that _M_finish is + not null. + * testsuite/23_containers/vector/capacity/114945.cc: New test. + +2025-04-01 Thomas Schwinge <tschwinge@baylibre.com> + + PR target/119369 + * config/cpu/gcn/cpu_defines.h: New. + * configure.host [GCN] (cpu_defines_dir): Point to it. + +2025-03-31 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/110498 + * include/bits/vector.tcc (vector<bool, A>::_M_reallocate): + Hoist loads of begin() and end() before allocation and use them + to state an unreachable condition. + * testsuite/23_containers/vector/bool/capacity/110498.cc: New + test. + +2025-03-31 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/114758 + * include/bits/vector.tcc (vector<bool, A>::_M_fill_insert): + Hoist loads of begin() and end() before allocation. + * testsuite/23_containers/vector/bool/capacity/114758.cc: New + test. + +2025-03-31 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/119550 + * acinclude.m4 (GLIBCXX_STRUCT_TM_TM_ZONE): New macro. + * config.h.in: Regenerate. + * configure: Regenerate. + * configure.ac: Use GLIBCXX_STRUCT_TM_TM_ZONE. + * include/bits/chrono_io.h (__formatter_chrono::_M_c): Check + _GLIBCXX_USE_STRUCT_TM_TM_ZONE instead of + _GLIBCXX_HAVE_STRUCT_TM_TM_ZONE. + +2025-03-31 Jonathan Wakely <jwakely@redhat.com> + + * config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Make + std::basic_string::_M_construct patterns more precise. + +2025-03-31 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/119545 + * include/std/tuple (operator==): Convert comparison results to + bool. + * testsuite/20_util/tuple/comparison_operators/119545.cc: New + test. + +2025-03-31 Tomasz Kamiński <tkaminsk@redhat.com> + + PR libstdc++/119517 + * include/bits/chrono_io.h (formatter): + Add __format::__char for _CharT and adjust parse and format + method signatures. + * testsuite/std/time/format/pr119517.cc: New test. + +2025-03-31 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/103827 + PR tree-optimization/80331 + PR tree-optimization/87502 + * config/abi/pre/gnu.ver (GLIBCXX_3.4.34): Use [jmy] rather than m + in pattern for _M_construct<bool>(char const*, size_t). + +2025-03-30 Jan Hubicka <hubicka@ucw.cz> + + PR tree-optimization/103827 + PR tree-optimization/80331 + PR tree-optimization/87502 + * config/abi/pre/gnu.ver: Add version for _M_construct<bool> + * include/bits/basic_string.h: (basic_string::_M_construct<bool>): Declare. + (basic_string constructors): Use it. + * include/bits/basic_string.tcc: (basic_string::_M_construct<bool>): New template. + * src/c++11/string-inst.cc: Instantated S::_M_construct<bool>. + +2025-03-28 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/117983 + * testsuite/23_containers/vector/modifiers/insert/117983.cc: New + test. + +2025-03-28 David Malcolm <dmalcolm@redhat.com> + + * testsuite/17_intro/shared_with_static_deps.cc: Fix malformed + dg-require-static-libstdcxx directive. + * testsuite/17_intro/static.cc: Likewise. + * testsuite/18_support/type_info/110572.cc: Likewise. + * testsuite/20_util/to_chars/4.cc: Likewise. + * testsuite/std/time/tzdb_list/pr118811.cc: Likewise. + +2025-03-27 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/101587 + * include/bits/ranges_uninitialized.h (__detail::__mindist): + New function object. + (ranges::uninitialized_copy, ranges::uninitialized_copy_n) + (ranges::uninitialized_move, ranges::uninitialized_move_n): Use + __mindist instead of std::min. + * testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc: + Check ranges with difference difference types. + * testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc: + Likewise. + +2025-03-27 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/chrono_io.h (__formatter_chrono::_M_c): Use + const_cast when setting tm.tm_zone. + +2025-03-27 Jonathan Wakely <jwakely@redhat.com> + + * src/c++20/tzdata.zi: Import new file from 2025b release. + +2025-03-27 Sam James <sam@gentoo.org> + + * testsuite/std/format/string_neg.cc: Add missing brace for dg-error. + +2025-03-27 Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> + + PR libstdc++/119488 + * include/bits/version.def (constexpr_algorithms): Bump + the feature-testing macro. + * include/bits/version.h: Regenerate. + * testsuite/25_algorithms/cpp_lib_constexpr.cc: Test the + bumped value for the feature-testing macro. + +2025-03-27 Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> + + * include/bits/algorithmfwd.h (stable_partition): Mark it + as constexpr for C++26. + * include/bits/ranges_algo.h (__stable_partition_fn): Likewise. + * include/bits/stl_algo.h (stable_partition): Mark it as + constexpr for C++26; during constant evaluation use a new + codepath where a temporary buffer of 1 element is used. + * testsuite/25_algorithms/headers/algorithm/synopsis.cc + (stable_partition): Add constexpr. + * testsuite/25_algorithms/stable_partition/constexpr.cc: New test. + +2025-03-27 Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> + + * include/bits/algorithmfwd.h (inplace_merge): Mark it as + constexpr for C++26. + * include/bits/ranges_algo.h (__inplace_merge_fn): Likewise. + * include/bits/stl_algo.h (inplace_merge): Mark it as constexpr; + during constant evaluation, dispatch to the non-allocating + codepath. + * testsuite/25_algorithms/headers/algorithm/synopsis.cc + (inplace_merge): Add constexpr. + * testsuite/25_algorithms/inplace_merge/constexpr.cc: New test. + +2025-03-27 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/119469 + * include/bits/iterator_concepts.h (_IterMove::__result): Use + decltype-specifier instead of an explicit type. + * testsuite/24_iterators/customization_points/iter_move.cc: + Check results for function references. + 2025-03-26 Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> * include/bits/version.def (constexpr_algorithms): Change diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index e668d2d..02fd349e 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -5745,6 +5745,41 @@ AC_DEFUN([GLIBCXX_ZONEINFO_DIR], [ ]) dnl +dnl Check for a tm_zone member in struct tm. +dnl +dnl This member is defined as const char* in Glibc, newlib, POSIX.1-2024, +dnl and as char* in BSD (including macOS). +dnl +dnl Defines: +dnl _GLIBCXX_USE_STRUCT_TM_TM_ZONE if struct tm has a tm_zone member. +dnl +AC_DEFUN([GLIBCXX_STRUCT_TM_TM_ZONE], [ + + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -std=c++20" + + AC_CACHE_CHECK([for tm_zone member of struct tm], glibcxx_cv_tm_zone, [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <time.h> + ], + [struct tm t{}; t.tm_zone = (char*)0;] + )], + [glibcxx_cv_tm_zone=yes], + [glibcxx_cv_tm_zone=no] + ) + ]) + + if test $glibcxx_cv_tm_zone = yes; then + AC_DEFINE(_GLIBCXX_USE_STRUCT_TM_TM_ZONE, 1, + [Define if struct tm has a tm_zone member.]) + fi + + CXXFLAGS="$ac_save_CXXFLAGS" + AC_LANG_RESTORE +]) + +dnl dnl Check whether lock tables can be aligned to avoid false sharing. dnl dnl Defines: diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index be151f4..77bbaf1 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -74,10 +74,6 @@ don't. */ #undef HAVE_DECL_STRNLEN -/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. - */ -#undef HAVE_DECL_TZNAME - /* Define to 1 if you have the <dirent.h> header file. */ #undef HAVE_DIRENT_H @@ -412,9 +408,6 @@ /* Define to 1 if `d_type' is a member of `struct dirent'. */ #undef HAVE_STRUCT_DIRENT_D_TYPE -/* Define to 1 if `tm_zone' is a member of `struct tm'. */ -#undef HAVE_STRUCT_TM_TM_ZONE - /* Define if strxfrm_l is available in <string.h>. */ #undef HAVE_STRXFRM_L @@ -506,17 +499,9 @@ /* Define to 1 if the target supports thread-local storage. */ #undef HAVE_TLS -/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use - `HAVE_STRUCT_TM_TM_ZONE' instead. */ -#undef HAVE_TM_ZONE - /* Define if truncate is available in <unistd.h>. */ #undef HAVE_TRUNCATE -/* Define to 1 if you don't have `tm_zone' but do have the external array - `tzname'. */ -#undef HAVE_TZNAME - /* Define to 1 if you have the <uchar.h> header file. */ #undef HAVE_UCHAR_H @@ -605,9 +590,6 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* Define to 1 if your <sys/time.h> declares `struct tm'. */ -#undef TM_IN_SYS_TIME - /* Version number of package */ #undef VERSION @@ -906,6 +888,9 @@ /* Define to restrict std::__basic_file<> to stdio APIs. */ #undef _GLIBCXX_USE_STDIO_PURE +/* Define if struct tm has a tm_zone member. */ +#undef _GLIBCXX_USE_STRUCT_TM_TM_ZONE + /* Define if struct stat has timespec members. */ #undef _GLIBCXX_USE_ST_MTIM diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index adadc62..29bc7d8 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -1767,7 +1767,8 @@ GLIBCXX_3.4.21 { _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE10_S_compareE[jmy][jmy]; _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE11_M_capacityE[jmy]; _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_Alloc_hiderC[12]EP[cw]RKS3_; - _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M*; + _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M_constructE[jmy][cw]; + _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M_constructI[NP]*; _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE13*; _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE14_M_replace_aux*; _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE1[68-9]*; @@ -2540,6 +2541,9 @@ GLIBCXX_3.4.34 { _ZNSt8__format25__locale_encoding_to_utf8ERKSt6localeSt17basic_string_viewIcSt11char_traitsIcEEPv; # __sso_string constructor and destructor _ZNSt12__sso_string[CD][12]Ev; + # void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<bool>(char const*, size_t) + # and wide char version + _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M_constructILb[01]EEEvPK[cw][jmy]; } GLIBCXX_3.4.33; # Symbols in the support library (libsupc++) have their own tag. diff --git a/libstdc++-v3/config/cpu/gcn/cpu_defines.h b/libstdc++-v3/config/cpu/gcn/cpu_defines.h new file mode 100644 index 0000000..028bfb0 --- /dev/null +++ b/libstdc++-v3/config/cpu/gcn/cpu_defines.h @@ -0,0 +1,55 @@ +// Specific definitions for GCN platforms -*- C++ -*- + +// Copyright (C) 2025 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/cpu_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _GLIBCXX_CPU_DEFINES +#define _GLIBCXX_CPU_DEFINES 1 + +/* GCN appears to run into issues similar to PR69506: + + ld: error: relocation R_AMDGPU_REL32_LO cannot be used against symbol '_ZGTtnam'; recompile with -fPIC + >>> defined in [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a(cow-stdexcept.o) + >>> referenced by cow-stdexcept.cc:259 ([...]/libstdc++-v3/src/c++11/cow-stdexcept.cc:259) + >>> cow-stdexcept.o:(_txnal_cow_string_C1_for_exceptions(void*, char const*, void*)) in archive [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a + + ld: error: relocation R_AMDGPU_REL32_HI cannot be used against symbol '_ZGTtnam'; recompile with -fPIC + >>> defined in [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a(cow-stdexcept.o) + >>> referenced by cow-stdexcept.cc:259 ([...]/source-gcc/libstdc++-v3/src/c++11/cow-stdexcept.cc:259) + >>> cow-stdexcept.o:(_txnal_cow_string_C1_for_exceptions(void*, char const*, void*)) in archive [...]/amdgcn-amdhsa/./libstdc++-v3/src/.libs/libstdc++.a + + [...] + + ..., which is: + + $ c++filt _ZGTtnam + transaction clone for operator new[](unsigned long) + + ..., and similarly for other libitm symbols. See PR119369. */ +#define _GLIBCXX_USE_WEAK_REF 0 + +#endif diff --git a/libstdc++-v3/config/cpu/nvptx/t-nvptx b/libstdc++-v3/config/cpu/nvptx/t-nvptx deleted file mode 100644 index a2f0f2d..0000000 --- a/libstdc++-v3/config/cpu/nvptx/t-nvptx +++ /dev/null @@ -1,7 +0,0 @@ -# Per-file flags, see '../../../configure.host', "inject per-file flags". - -# 'ptxas'/CUDA Driver rejects objects with a lot of global constant data: -# ptxas error : File uses too much global constant data ([...]) -# Cut short the assembly-time check; defer to actual use of the object file. -AM_MAKEFLAGS += CXXFLAGS-src/c++17/floating_to_chars.lo=-Wa,--no-verify -AM_MAKEFLAGS += CXXFLAGS-src/c++20/tzdb.lo=-Wa,--no-verify diff --git a/libstdc++-v3/config/os/hpux/os_defines.h b/libstdc++-v3/config/os/hpux/os_defines.h index 30bd4c7..d3a6c5a 100644 --- a/libstdc++-v3/config/os/hpux/os_defines.h +++ b/libstdc++-v3/config/os/hpux/os_defines.h @@ -57,7 +57,7 @@ We also force _GLIBCXX_USE_LONG_LONG here so that we don't have to bastardize configure to deal with this sillyness. */ -#ifdef __cplusplus +#if __cplusplus >= 201103L namespace std { extern "C" diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 67d2b8c..56d0bcb 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -2731,63 +2731,6 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl - -# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES -# ---------------------------------------------------- -# Tries to find if the field MEMBER exists in type AGGR, after including -# INCLUDES, setting cache variable VAR accordingly. -ac_fn_c_check_member () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -$as_echo_n "checking for $2.$3... " >&6; } -if eval \${$4+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (sizeof ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - eval "$4=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$4 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_member cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -12337,7 +12280,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12340 "configure" +#line 12283 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12443,7 +12386,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12446 "configure" +#line 12389 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16239,7 +16182,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } # Fake what AC_TRY_COMPILE does. cat > conftest.$ac_ext << EOF -#line 16242 "configure" +#line 16185 "configure" int main() { typedef bool atomic_type; @@ -16274,7 +16217,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16277 "configure" +#line 16220 "configure" int main() { typedef short atomic_type; @@ -16309,7 +16252,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16312 "configure" +#line 16255 "configure" int main() { // NB: _Atomic_word not necessarily int. @@ -16345,7 +16288,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16348 "configure" +#line 16291 "configure" int main() { typedef long long atomic_type; @@ -16501,7 +16444,7 @@ $as_echo "mutex" >&6; } # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16504 "configure" +#line 16447 "configure" int main() { _Decimal32 d1; @@ -16543,7 +16486,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16546 "configure" +#line 16489 "configure" template<typename T1, typename T2> struct same { typedef T2 type; }; @@ -54482,6 +54425,65 @@ _ACEOF fi +# For std::chrono formatters to use tm::tm_zone + + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -std=c++20" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tm_zone member of struct tm" >&5 +$as_echo_n "checking for tm_zone member of struct tm... " >&6; } +if ${glibcxx_cv_tm_zone+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <time.h> + +int +main () +{ +struct tm t{}; t.tm_zone = (char*)0; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + glibcxx_cv_tm_zone=yes +else + glibcxx_cv_tm_zone=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_tm_zone" >&5 +$as_echo "$glibcxx_cv_tm_zone" >&6; } + + if test $glibcxx_cv_tm_zone = yes; then + +$as_echo "#define _GLIBCXX_USE_STRUCT_TM_TM_ZONE 1" >>confdefs.h + + fi + + CXXFLAGS="$ac_save_CXXFLAGS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + # For src/c++11/shared_ptr.cc alignment. @@ -54697,112 +54699,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 -$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } -if ${ac_cv_struct_tm+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <sys/types.h> -#include <time.h> - -int -main () -{ -struct tm tm; - int *p = &tm.tm_sec; - return !p; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_struct_tm=time.h -else - ac_cv_struct_tm=sys/time.h -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 -$as_echo "$ac_cv_struct_tm" >&6; } -if test $ac_cv_struct_tm = sys/time.h; then - -$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h - -fi - -ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include <sys/types.h> -#include <$ac_cv_struct_tm> - -" -if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_TM_TM_ZONE 1 -_ACEOF - - -fi - -if test "$ac_cv_member_struct_tm_tm_zone" = yes; then - -$as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h - -else - ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include <time.h> -" -if test "x$ac_cv_have_decl_tzname" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_TZNAME $ac_have_decl -_ACEOF - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5 -$as_echo_n "checking for tzname... " >&6; } -if ${ac_cv_var_tzname+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test x$gcc_no_link = xyes; then - as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 -fi -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <time.h> -#if !HAVE_DECL_TZNAME -extern char *tzname[]; -#endif - -int -main () -{ -return tzname[0][0]; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_var_tzname=yes -else - ac_cv_var_tzname=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5 -$as_echo "$ac_cv_var_tzname" >&6; } - if test $ac_cv_var_tzname = yes; then - -$as_echo "#define HAVE_TZNAME 1" >>confdefs.h - - fi -fi - - # Define documentation rules conditionally. # See if makeinfo has been installed and is modern enough diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index fe0cdde..a6c01b2 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -572,6 +572,9 @@ GLIBCXX_EMERGENCY_EH_ALLOC # For src/c++20/tzdb.cc defaults. GLIBCXX_ZONEINFO_DIR +# For std::chrono formatters to use tm::tm_zone +GLIBCXX_STRUCT_TM_TM_ZONE + # For src/c++11/shared_ptr.cc alignment. GLIBCXX_CHECK_ALIGNAS_CACHELINE @@ -584,8 +587,6 @@ GLIBCXX_CHECK_FILEBUF_NATIVE_HANDLES # For std::text_encoding GLIBCXX_CHECK_TEXT_ENCODING -AC_STRUCT_TIMEZONE - # Define documentation rules conditionally. # See if makeinfo has been installed and is modern enough diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host index cb4c28a..8375764 100644 --- a/libstdc++-v3/configure.host +++ b/libstdc++-v3/configure.host @@ -147,6 +147,9 @@ cpu_include_dir=cpu/${try_cpu} # Set specific CPU overrides for cpu_defines_dir. Most can just use generic. # THIS TABLE IS SORTED. KEEP IT THAT WAY. case "${host_cpu}" in + amdgcn) + cpu_defines_dir=cpu/gcn + ;; arm*) cpu_defines_dir=cpu/arm ;; @@ -371,11 +374,6 @@ case "${host}" in port_specific_symbol_files="\$(srcdir)/../config/os/gnu-linux/arm-eabi-extra.ver" ;; nvptx-*-none) - # For 'make all-target-libstdc++-v3', we need to inject per-file flags: - OPTIMIZE_CXXFLAGS="${OPTIMIZE_CXXFLAGS} \$(CXXFLAGS-\$(subdir)/\$@)" - # ..., see: - tmake_file="$tmake_file cpu/nvptx/t-nvptx" - # For 'make all-target-libstdc++-v3', re 'alloca'/VLA usage: EXTRA_CFLAGS="${EXTRA_CFLAGS} -mfake-ptx-alloca" OPTIMIZE_CXXFLAGS="${OPTIMIZE_CXXFLAGS} -mfake-ptx-alloca" diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 4dc771a..537774c 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -195,6 +195,7 @@ bits_headers = \ ${bits_srcdir}/cow_string.h \ ${bits_srcdir}/deque.tcc \ ${bits_srcdir}/erase_if.h \ + ${bits_srcdir}/formatfwd.h \ ${bits_srcdir}/forward_list.h \ ${bits_srcdir}/forward_list.tcc \ ${bits_srcdir}/fs_dir.h \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 0e3d09b..7b96b22 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -548,6 +548,7 @@ bits_freestanding = \ @GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/cow_string.h \ @GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/deque.tcc \ @GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/erase_if.h \ +@GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/formatfwd.h \ @GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/forward_list.h \ @GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/forward_list.tcc \ @GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/fs_dir.h \ diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index e3b484d..886e7e6 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -45,7 +45,9 @@ #include <initializer_list> #endif -#if __cplusplus >= 201703L +#include <bits/version.h> + +#ifdef __glibcxx_string_view // >= C++17 # include <string_view> #endif @@ -53,7 +55,6 @@ # include <charconv> #endif -#include <bits/version.h> #if ! _GLIBCXX_USE_CXX11_ABI # include "cow_string.h" @@ -146,7 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return __p; } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 // A helper type for avoiding boiler-plate. typedef basic_string_view<_CharT, _Traits> __sv_type; @@ -341,6 +342,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 void _M_construct(size_type __req, _CharT __c); + // Construct using block of memory of known size. + // If _Terminated is true assume that source is already 0 terminated. + template<bool _Terminated> + _GLIBCXX20_CONSTEXPR + void + _M_construct(const _CharT *__c, size_type __n); + _GLIBCXX20_CONSTEXPR allocator_type& _M_get_allocator() @@ -561,8 +569,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 : _M_dataplus(_M_local_data(), _Alloc_traits::_S_select_on_copy(__str._M_get_allocator())) { - _M_construct(__str._M_data(), __str._M_data() + __str.length(), - std::forward_iterator_tag()); + _M_construct<true>(__str._M_data(), __str.length()); } // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -782,7 +789,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 #endif } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Construct string from a substring of a string_view. * @param __t Source object convertible to string view. @@ -938,7 +945,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #endif // C++11 -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Set value to string constructed from a string_view. * @param __svt An object convertible to string_view. @@ -1433,7 +1440,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 { return this->append(__l.begin(), __l.size()); } #endif // C++11 -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Append a string_view. * @param __svt An object convertible to string_view to be appended. @@ -1550,7 +1557,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 append(_InputIterator __first, _InputIterator __last) { return this->replace(end(), end(), __first, __last); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view /** * @brief Append a string_view. * @param __svt An object convertible to string_view to be appended. @@ -1803,7 +1810,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } #endif // C++11 -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Set value from a string_view. * @param __svt The source object convertible to string_view. @@ -2084,7 +2091,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return iterator(_M_data() + __pos); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Insert a string_view. * @param __pos Position in string to insert at. @@ -2536,7 +2543,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 { return this->replace(__i1, __i2, __l.begin(), __l.size()); } #endif // C++11 -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Replace range of characters with string_view. * @param __pos The position to replace at. @@ -2735,7 +2742,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _GLIBCXX_NOEXCEPT { return this->find(__str.data(), __pos, __str.size()); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find position of a string_view. * @param __svt The object convertible to string_view to locate. @@ -2801,7 +2808,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _GLIBCXX_NOEXCEPT { return this->rfind(__str.data(), __pos, __str.size()); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find last position of a string_view. * @param __svt The object convertible to string_view to locate. @@ -2885,7 +2892,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _GLIBCXX_NOEXCEPT { return this->find_first_of(__str.data(), __pos, __str.size()); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find position of a character of a string_view. * @param __svt An object convertible to string_view containing @@ -2974,7 +2981,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _GLIBCXX_NOEXCEPT { return this->find_last_of(__str.data(), __pos, __str.size()); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find last position of a character of string. * @param __svt An object convertible to string_view containing @@ -3062,7 +3069,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _GLIBCXX_NOEXCEPT { return this->find_first_not_of(__str.data(), __pos, __str.size()); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find position of a character not in a string_view. * @param __svt A object convertible to string_view containing @@ -3149,7 +3156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _GLIBCXX_NOEXCEPT { return this->find_last_not_of(__str.data(), __pos, __str.size()); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find last position of a character not in a string_view. * @param __svt An object convertible to string_view containing @@ -3265,7 +3272,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return __r; } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Compare to a string_view. * @param __svt An object convertible to string_view to compare against. @@ -4599,7 +4606,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 constexpr #endif inline wstring -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 __to_wstring_numeric(string_view __s) #else __to_wstring_numeric(const string& __s) @@ -4802,7 +4809,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } // inline namespace literals #endif // __glibcxx_string_udls -#if __cplusplus >= 201703L +#ifdef __glibcxx_variant // >= C++17 namespace __detail::__variant { template<typename> struct _Never_valueless_alt; // see <variant> diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 7c44753..02230ac 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -276,6 +276,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_set_length(__n); } + // Length of string constructed is easier to propagate inter-procedurally + // than difference between iterators. + template<typename _CharT, typename _Traits, typename _Alloc> + template<bool _Terminated> + _GLIBCXX20_CONSTEXPR + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_construct(const _CharT* __str, size_type __n) + { + if (__n > size_type(_S_local_capacity)) + { + _M_data(_M_create(__n, size_type(0))); + _M_capacity(__n); + } + else + _M_init_local_buf(); + + if (__n || _Terminated) + this->_S_copy(_M_data(), __str, __n + _Terminated); + + _M_length(__n); + if (!_Terminated) + traits_type::assign(_M_data()[__n], _CharT()); + } + template<typename _CharT, typename _Traits, typename _Alloc> _GLIBCXX20_CONSTEXPR void diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h index c55b651..d872109 100644 --- a/libstdc++-v3/include/bits/chrono_io.h +++ b/libstdc++-v3/include/bits/chrono_io.h @@ -905,7 +905,7 @@ namespace __format // time zone info available for the time in __tm. __tm.tm_isdst = -1; -#ifdef _GLIBCXX_HAVE_STRUCT_TM_TM_ZONE +#ifdef _GLIBCXX_USE_STRUCT_TM_TM_ZONE // POSIX.1-2024 adds tm.tm_zone which will be used for %Z. // BSD has had tm_zone since 1987 but as char* so cast away const. if constexpr (__is_time_point_v<_Tp>) @@ -1785,277 +1785,272 @@ namespace __format __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::day, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Day); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Day); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::day& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::day& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::month, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Month); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Month); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::month& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::month& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::year, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Year); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Year); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::year& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::year& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::weekday, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Weekday); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Weekday); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::weekday& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::weekday& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::weekday_indexed, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Weekday); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Weekday); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::weekday_indexed& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::weekday_indexed& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::weekday_last, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Weekday); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Weekday); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::weekday_last& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::weekday_last& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::month_day, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Month|__format::_Day); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Month|__format::_Day); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::month_day& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::month_day& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::month_day_last, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Month|__format::_Day); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Month|__format::_Day); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::month_day_last& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::month_day_last& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::month_weekday, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Month|__format::_Weekday); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Month|__format::_Weekday); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::month_weekday& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::month_weekday& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::month_weekday_last, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Month|__format::_Weekday); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Month|__format::_Weekday); } - template<typename _FormatContext> - typename _FormatContext::iterator + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator format(const chrono::month_weekday_last& __t, - _FormatContext& __fc) const + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::year_month, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Year|__format::_Month); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Year|__format::_Month); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::year_month& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::year_month& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::year_month_day, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Date); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Date); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::year_month_day& __t, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::year_month_day& __t, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::year_month_day_last, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Date); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Date); } - template<typename _FormatContext> - typename _FormatContext::iterator + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator format(const chrono::year_month_day_last& __t, - _FormatContext& __fc) const + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::year_month_weekday, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Date); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Date); } - template<typename _FormatContext> - typename _FormatContext::iterator + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator format(const chrono::year_month_weekday& __t, - _FormatContext& __fc) const + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::year_month_weekday_last, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_Date); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_Date); } - template<typename _FormatContext> - typename _FormatContext::iterator + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator format(const chrono::year_month_weekday_last& __t, - _FormatContext& __fc) const - { return _M_f._M_format(__t, __fc); } + basic_format_context<_Out, _CharT>& __fc) const + { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _Rep, typename _Period, typename _CharT> + template<typename _Rep, typename _Period, __format::__char _CharT> struct formatter<chrono::hh_mm_ss<chrono::duration<_Rep, _Period>>, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_TimeOfDay); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_TimeOfDay); } - template<typename _FormatContext> - typename _FormatContext::iterator + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator format(const chrono::hh_mm_ss<chrono::duration<_Rep, _Period>>& __t, - _FormatContext& __fc) const + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__t, __fc); } private: @@ -2063,34 +2058,34 @@ namespace __format }; #if _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::sys_info, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_ChronoParts{}); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_ChronoParts{}); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::sys_info& __i, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::sys_info& __i, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__i, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _CharT> + template<__format::__char _CharT> struct formatter<chrono::local_info, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_ChronoParts{}); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_ChronoParts{}); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::local_info& __i, _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::local_info& __i, + basic_format_context<_Out, _CharT>& __fc) const { return _M_f._M_format(__i, __fc); } private: @@ -2098,25 +2093,24 @@ namespace __format }; #endif - template<typename _Duration, typename _CharT> + template<typename _Duration, __format::__char _CharT> struct formatter<chrono::sys_time<_Duration>, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { - auto __next = _M_f._M_parse(__pc, __format::_ZonedDateTime); - if constexpr (!__stream_insertable) - if (_M_f._M_spec._M_chrono_specs.empty()) - __format::__invalid_chrono_spec(); // chrono-specs can't be empty - return __next; - } - - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::sys_time<_Duration>& __t, - _FormatContext& __fc) const - { return _M_f._M_format(__t, __fc); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { + auto __next = _M_f._M_parse(__pc, __format::_ZonedDateTime); + if constexpr (!__stream_insertable) + if (_M_f._M_spec._M_chrono_specs.empty()) + __format::__invalid_chrono_spec(); // chrono-specs can't be empty + return __next; + } + + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::sys_time<_Duration>& __t, + basic_format_context<_Out, _CharT>& __fc) const + { return _M_f._M_format(__t, __fc); } private: static constexpr bool __stream_insertable @@ -2126,19 +2120,18 @@ namespace __format __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _Duration, typename _CharT> + template<typename _Duration, __format::__char _CharT> struct formatter<chrono::utc_time<_Duration>, _CharT> : __format::__formatter_chrono<_CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::utc_time<_Duration>& __t, - _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::utc_time<_Duration>& __t, + basic_format_context<_Out, _CharT>& __fc) const { // Adjust by removing leap seconds to get equivalent sys_time. // We can't just use clock_cast because we want to know if the time @@ -2161,19 +2154,18 @@ namespace __format __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _Duration, typename _CharT> + template<typename _Duration, __format::__char _CharT> struct formatter<chrono::tai_time<_Duration>, _CharT> : __format::__formatter_chrono<_CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::tai_time<_Duration>& __t, - _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::tai_time<_Duration>& __t, + basic_format_context<_Out, _CharT>& __fc) const { // Convert to __local_time_fmt with abbrev "TAI" and offset 0s. // We use __local_time_fmt and not sys_time (as the standard implies) @@ -2193,19 +2185,18 @@ namespace __format __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _Duration, typename _CharT> + template<typename _Duration, __format::__char _CharT> struct formatter<chrono::gps_time<_Duration>, _CharT> : __format::__formatter_chrono<_CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::gps_time<_Duration>& __t, - _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::gps_time<_Duration>& __t, + basic_format_context<_Out, _CharT>& __fc) const { // Convert to __local_time_fmt with abbrev "GPS" and offset 0s. // We use __local_time_fmt and not sys_time (as the standard implies) @@ -2225,72 +2216,69 @@ namespace __format __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _Duration, typename _CharT> + template<typename _Duration, __format::__char _CharT> struct formatter<chrono::file_time<_Duration>, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::file_time<_Duration>& __t, - _FormatContext& __ctx) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::file_time<_Duration>& __t, + basic_format_context<_Out, _CharT>& __fc) const { using namespace chrono; - return _M_f._M_format(chrono::clock_cast<system_clock>(__t), __ctx); + return _M_f._M_format(chrono::clock_cast<system_clock>(__t), __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _Duration, typename _CharT> + template<typename _Duration, __format::__char _CharT> struct formatter<chrono::local_time<_Duration>, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_DateTime); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_DateTime); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::local_time<_Duration>& __t, - _FormatContext& __ctx) const - { return _M_f._M_format(__t, __ctx); } + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::local_time<_Duration>& __t, + basic_format_context<_Out, _CharT>& __fc) const + { return _M_f._M_format(__t, __fc); } private: __format::__formatter_chrono<_CharT> _M_f; }; - template<typename _Duration, typename _CharT> + template<typename _Duration, __format::__char _CharT> struct formatter<chrono::__detail::__local_time_fmt<_Duration>, _CharT> { - template<typename _ParseContext> - constexpr typename _ParseContext::iterator - parse(_ParseContext& __pc) - { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f._M_parse(__pc, __format::_ZonedDateTime); } - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::__detail::__local_time_fmt<_Duration>& __t, - _FormatContext& __ctx) const - { return _M_f._M_format(__t, __ctx, /* use %Z for {} */ true); } + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::__detail::__local_time_fmt<_Duration>& __t, + basic_format_context<_Out, _CharT>& __fc) const + { return _M_f._M_format(__t, __fc, /* use %Z for {} */ true); } private: __format::__formatter_chrono<_CharT> _M_f; }; #if _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI - template<typename _Duration, typename _TimeZonePtr, typename _CharT> + template<typename _Duration, typename _TimeZonePtr, __format::__char _CharT> struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : formatter<chrono::__detail::__local_time_fmt_for<_Duration>, _CharT> { - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::zoned_time<_Duration, _TimeZonePtr>& __tp, - _FormatContext& __ctx) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::zoned_time<_Duration, _TimeZonePtr>& __tp, + basic_format_context<_Out, _CharT>& __fc) const { using _Ltf = chrono::__detail::__local_time_fmt_for<_Duration>; using _Base = formatter<_Ltf, _CharT>; @@ -2298,20 +2286,20 @@ namespace __format const auto __lf = chrono::local_time_format(__tp.get_local_time(), &__info.abbrev, &__info.offset); - return _Base::format(__lf, __ctx); + return _Base::format(__lf, __fc); } }; #endif // Partial specialization needed for %c formatting of __utc_leap_second. - template<typename _Duration, typename _CharT> + template<typename _Duration, __format::__char _CharT> struct formatter<chrono::__detail::__utc_leap_second<_Duration>, _CharT> : formatter<chrono::utc_time<_Duration>, _CharT> { - template<typename _FormatContext> - typename _FormatContext::iterator - format(const chrono::__detail::__utc_leap_second<_Duration>& __t, - _FormatContext& __fc) const + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const chrono::__detail::__utc_leap_second<_Duration>& __t, + basic_format_context<_Out, _CharT>& __fc) const { return this->_M_f._M_format(__t, __fc); } }; diff --git a/libstdc++-v3/include/bits/cow_string.h b/libstdc++-v3/include/bits/cow_string.h index 740e046..d5b3979 100644 --- a/libstdc++-v3/include/bits/cow_string.h +++ b/libstdc++-v3/include/bits/cow_string.h @@ -467,7 +467,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _S_empty_rep() _GLIBCXX_NOEXCEPT { return _Rep::_S_empty_rep(); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 // A helper type for avoiding boiler-plate. typedef basic_string_view<_CharT, _Traits> __sv_type; @@ -685,7 +685,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_dataplus(_S_construct(__beg, __end, __a), __a) { } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Construct string from a substring of a string_view. * @param __t Source object convertible to string view. @@ -775,7 +775,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif // C++11 -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Set value to string constructed from a string_view. * @param __svt An object convertible to string_view. @@ -1246,7 +1246,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return this->append(__l.begin(), __l.size()); } #endif // C++11 -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Append a string_view. * @param __svt The object convertible to string_view to be appended. @@ -1338,7 +1338,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION append(_InputIterator __first, _InputIterator __last) { return this->replace(_M_iend(), _M_iend(), __first, __last); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Append a string_view. * @param __svt The object convertible to string_view to be appended. @@ -1496,7 +1496,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return this->assign(__l.begin(), __l.size()); } #endif // C++11 -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Set value from a string_view. * @param __svt The source object convertible to string_view. @@ -1703,7 +1703,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return iterator(_M_data() + __pos); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Insert a string_view. * @param __pos Position in string to insert at. @@ -2092,7 +2092,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return this->replace(__i1, __i2, __l.begin(), __l.end()); } #endif // C++11 -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Replace range of characters with string_view. * @param __pos The position to replace at. @@ -2354,7 +2354,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_type find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find position of a string_view. * @param __svt The object convertible to string_view to locate. @@ -2432,7 +2432,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_type rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find last position of a string_view. * @param __svt The object convertible to string_view to locate. @@ -2515,7 +2515,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT { return this->find(__c, __pos); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find position of a character of a string_view. * @param __svt An object convertible to string_view containing @@ -2599,7 +2599,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT { return this->rfind(__c, __pos); } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find last position of a character of string. * @param __svt An object convertible to string_view containing @@ -2680,7 +2680,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find position of a character not in a string_view. * @param __svt An object convertible to string_view containing @@ -2762,7 +2762,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION find_last_not_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Find last position of a character not in a string_view. * @param __svt An object convertible to string_view containing @@ -2824,7 +2824,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __r; } -#if __cplusplus >= 201703L +#ifdef __glibcxx_string_view // >= C++17 /** * @brief Compare to a string_view. * @param __svt An object convertible to string_view to compare against. diff --git a/libstdc++-v3/include/bits/formatfwd.h b/libstdc++-v3/include/bits/formatfwd.h new file mode 100644 index 0000000..44922cb --- /dev/null +++ b/libstdc++-v3/include/bits/formatfwd.h @@ -0,0 +1,71 @@ +// <format> Formatting -*- C++ -*- + +// Copyright The GNU Toolchain Authors. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file bits/formatfwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{format} + */ + +#ifndef _GLIBCXX_FORMAT_FWD_H +#define _GLIBCXX_FORMAT_FWD_H 1 + +#ifdef _GLIBCXX_SYSHDR +#pragma GCC system_header +#endif + +// <bits/version.h> must have been included before this header: +#ifdef __glibcxx_format // C++ >= 20 && HOSTED + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // [format.context], class template basic_format_context + template<typename _Out, typename _CharT> class basic_format_context; + + // [format.parse.ctx], class template basic_format_parse_context + template<typename _CharT> class basic_format_parse_context; + + // [format.formatter], formatter + template<typename _Tp, typename _CharT = char> struct formatter; + +namespace __format +{ +#ifdef _GLIBCXX_USE_WCHAR_T + template<typename _CharT> + concept __char = same_as<_CharT, char> || same_as<_CharT, wchar_t>; +#else + template<typename _CharT> + concept __char = same_as<_CharT, char>; +#endif + + template<__char _CharT> + struct __formatter_int; +} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // __glibcxx_format +#pragma GCC diagnostic pop +#endif // _GLIBCXX_FORMAT_FWD_H diff --git a/libstdc++-v3/include/bits/ranges_uninitialized.h b/libstdc++-v3/include/bits/ranges_uninitialized.h index b558007..12a714b 100644 --- a/libstdc++-v3/include/bits/ranges_uninitialized.h +++ b/libstdc++-v3/include/bits/ranges_uninitialized.h @@ -263,26 +263,6 @@ namespace ranges inline constexpr __uninitialized_value_construct_n_fn uninitialized_value_construct_n; - namespace __detail - { - // This is only intended for finding smaller iterator differences below, - // not as a general purpose replacement for std::min. - struct __mindist_fn - { - template<typename _Dp1, typename _Dp2> - constexpr common_type_t<_Dp1, _Dp2> - operator()(_Dp1 __d1, _Dp2 __d2) const noexcept - { - // Every C++20 iterator I satisfies weakly_incrementable<I> which - // requires signed-integer-like<iter_difference_t<I>>. - static_assert(std::__detail::__is_signed_integer_like<_Dp1>); - static_assert(std::__detail::__is_signed_integer_like<_Dp2>); - return std::min<common_type_t<_Dp1, _Dp2>>(__d1, __d2); - } - }; - inline constexpr __mindist_fn __mindist{}; - } - template<typename _Iter, typename _Out> using uninitialized_copy_result = in_out_result<_Iter, _Out>; @@ -305,10 +285,10 @@ namespace ranges && is_trivially_assignable_v<_OutType&, iter_reference_t<_Iter>>) { - auto __d1 = __ilast - __ifirst; - auto __d2 = __olast - __ofirst; - return ranges::copy_n(std::move(__ifirst), - __detail::__mindist(__d1, __d2), __ofirst); + auto __d = __ilast - __ifirst; + if (auto __d2 = __olast - __ofirst; __d2 < __d) + __d = static_cast<iter_difference_t<_Iter>>(__d2); + return ranges::copy_n(std::move(__ifirst), __d, __ofirst); } else { @@ -356,9 +336,9 @@ namespace ranges && is_trivially_assignable_v<_OutType&, iter_reference_t<_Iter>>) { - auto __d = __olast - __ofirst; - return ranges::copy_n(std::move(__ifirst), - __detail::__mindist(__n, __d), __ofirst); + if (auto __d = __olast - __ofirst; __d < __n) + __n = static_cast<iter_difference_t<_Iter>>(__d); + return ranges::copy_n(std::move(__ifirst), __n, __ofirst); } else { @@ -397,11 +377,12 @@ namespace ranges && is_trivially_assignable_v<_OutType&, iter_rvalue_reference_t<_Iter>>) { - auto __d1 = __ilast - __ifirst; - auto __d2 = __olast - __ofirst; + auto __d = __ilast - __ifirst; + if (auto __d2 = __olast - __ofirst; __d2 < __d) + __d = static_cast<iter_difference_t<_Iter>>(__d2); auto [__in, __out] = ranges::copy_n(std::make_move_iterator(std::move(__ifirst)), - __detail::__mindist(__d1, __d2), __ofirst); + __d, __ofirst); return {std::move(__in).base(), __out}; } else @@ -452,10 +433,11 @@ namespace ranges && is_trivially_assignable_v<_OutType&, iter_rvalue_reference_t<_Iter>>) { - auto __d = __olast - __ofirst; + if (auto __d = __olast - __ofirst; __d < __n) + __n = static_cast<iter_difference_t<_Iter>>(__d); auto [__in, __out] = ranges::copy_n(std::make_move_iterator(std::move(__ifirst)), - __detail::__mindist(__n, __d), __ofirst); + __n, __ofirst); return {std::move(__in).base(), __out}; } else diff --git a/libstdc++-v3/include/bits/unicode.h b/libstdc++-v3/include/bits/unicode.h index 24b1ac3..99d972e 100644 --- a/libstdc++-v3/include/bits/unicode.h +++ b/libstdc++-v3/include/bits/unicode.h @@ -1039,6 +1039,8 @@ inline namespace __v16_0_0 string_view __s(__enc); if (__s.ends_with("//")) __s.remove_suffix(2); + if (__s.ends_with("LE") || __s.ends_with("BE")) + __s.remove_suffix(2); return __s == "16" || __s == "32"; } } diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index f197278d..66d73b4 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -768,6 +768,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER if (__navail >= __n) { + if (!this->_M_impl._M_finish) + __builtin_unreachable(); + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); this->_M_impl._M_finish = std::__uninitialized_default_n_a(this->_M_impl._M_finish, @@ -1106,9 +1109,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER vector<bool, _Alloc>:: _M_reallocate(size_type __n) { + const iterator __begin = begin(), __end = end(); + if (size_type(__end - __begin) > __n) + __builtin_unreachable(); _Bit_pointer __q = this->_M_allocate(__n); iterator __start(std::__addressof(*__q), 0); - iterator __finish(_M_copy_aligned(begin(), end(), __start)); + iterator __finish(_M_copy_aligned(__begin, __end, __start)); this->_M_deallocate(); this->_M_impl._M_start = __start; this->_M_impl._M_finish = __finish; @@ -1134,11 +1140,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { const size_type __len = _M_check_len(__n, "vector<bool>::_M_fill_insert"); + iterator __begin = begin(), __end = end(); _Bit_pointer __q = this->_M_allocate(__len); iterator __start(std::__addressof(*__q), 0); - iterator __i = _M_copy_aligned(begin(), __position, __start); + iterator __i = _M_copy_aligned(__begin, __position, __start); std::fill(__i, __i + difference_type(__n), __x); - iterator __finish = std::copy(__position, end(), + iterator __finish = std::copy(__position, __end, __i + difference_type(__n)); this->_M_deallocate(); this->_M_impl._M_end_of_storage = __q + _S_nword(__len); diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 1468c04..8f609b4 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -30,6 +30,7 @@ AutoGen Definitions version.tpl; // ftms = { // name = FTM NAME; // [stdname = FTM STANDARD MACRO NAME;] +// [no_stdname = true;] // values = { // v = VALUE FOR FTM IF MATCHING; // [extra_cond = STRING;] @@ -56,7 +57,8 @@ AutoGen Definitions version.tpl; // stdname configures the name of the *standard* macro emitted, i.e. it // replaces only the __cpp_lib_ macro in the emitted definition. Defaults to -// __cpp_lib_${name} +// __cpp_lib_${name}. If no_stdname exists (with any value), the stdname +// define is not emitted. // N.B This list needs to be in topological sort order, as later entries in // this list can and do use the earlier entries. @@ -1404,18 +1406,18 @@ ftms = { }; }; -// ftms = { - // name = format_ranges; +ftms = { + name = format_ranges; // 202207 P2286R8 Formatting Ranges // 202207 P2585R1 Improving default container formatting // LWG3750 Too many papers bump __cpp_lib_format - // TODO: #define __cpp_lib_format_ranges 202207L - // values = { - // v = 202207; - // cxxmin = 23; - // hosted = yes; - // }; -// }; + no_stdname = true; // TODO remove + values = { + v = 1; // TODO 202207 + cxxmin = 23; + hosted = yes; + }; +}; ftms = { name = freestanding_algorithm; diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index f7c9849..f05c3fd 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -1555,6 +1555,15 @@ #endif /* !defined(__cpp_lib_expected) && defined(__glibcxx_want_expected) */ #undef __glibcxx_want_expected +#if !defined(__cpp_lib_format_ranges) +# if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED +# define __glibcxx_format_ranges 1L +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_format_ranges) +# endif +# endif +#endif /* !defined(__cpp_lib_format_ranges) && defined(__glibcxx_want_format_ranges) */ +#undef __glibcxx_want_format_ranges + #if !defined(__cpp_lib_freestanding_algorithm) # if (__cplusplus >= 202100L) # define __glibcxx_freestanding_algorithm 202311L diff --git a/libstdc++-v3/include/bits/version.tpl b/libstdc++-v3/include/bits/version.tpl index dd5f851..ccda71d 100644 --- a/libstdc++-v3/include/bits/version.tpl +++ b/libstdc++-v3/include/bits/version.tpl @@ -143,13 +143,15 @@ h }*/# /*{(unless (first-for?) "el")}*/if /*{(generate-cond)}*/ # define __glibcxx_/*{name}*/ /*{v}*/L -# if defined(__glibcxx_want_all) || defined(__glibcxx_want_/*{name}*/) +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_/*{name}*/)/*{ + IF (not (exist? "no_stdname")) }*/ # define /*{ ;; Compute the name for this FTM based on stdname/name. (if (exist? "stdname") (get "stdname") (format #f "__cpp_lib_~a" (get "name"))) -}*/ /*{v}*/L +}*/ /*{v}*/L/*{ + ENDIF no_std_name }*/ # endif /*{ ENDFOR values }*/# endif diff --git a/libstdc++-v3/include/std/flat_set b/libstdc++-v3/include/std/flat_set index a7b0b8a..3e15d1a 100644 --- a/libstdc++-v3/include/std/flat_set +++ b/libstdc++-v3/include/std/flat_set @@ -350,12 +350,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return _M_cont.max_size(); } // modifiers - template<typename... _Args> + template<typename _Arg, typename... _Args> pair<iterator, bool> - _M_try_emplace(optional<const_iterator> __hint, _Args&&... __args) + _M_try_emplace(optional<const_iterator> __hint, _Arg&& __arg, _Args&&... __args) { // TODO: Simplify and audit the hint handling. - value_type __k(std::forward<_Args>(__args)...); + auto&& __k = [&] -> decltype(auto) { + if constexpr (sizeof...(_Args) == 0 + && same_as<remove_cvref_t<_Arg>, value_type>) + return std::forward<_Arg>(__arg); + else + return value_type(std::forward<_Arg>(__arg), + std::forward<_Args>(__args)...); + }(); typename container_type::iterator __it; int __r = -1, __s = -1; if (__hint.has_value() @@ -397,12 +404,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return {__it, false}; auto __guard = _M_make_clear_guard(); - __it = _M_cont.insert(__it, std::move(__k)); + __it = _M_cont.insert(__it, std::forward<decltype(__k)>(__k)); __guard._M_disable(); return {__it, true}; } template<typename... _Args> + pair<iterator, bool> + _M_try_emplace(optional<const_iterator> __hint) + { return _M_try_emplace(__hint, value_type()); } + + template<typename... _Args> requires is_constructible_v<value_type, _Args...> __emplace_result_t emplace(_Args&&... __args) diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index c3327e1..01a5314 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -52,6 +52,7 @@ #include <string_view> #include <string> #include <bits/monostate.h> +#include <bits/formatfwd.h> #include <bits/ranges_base.h> // input_range, range_reference_t #include <bits/ranges_util.h> // subrange #include <bits/ranges_algobase.h> // ranges::copy @@ -73,9 +74,6 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - // [format.context], class template basic_format_context - template<typename _Out, typename _CharT> class basic_format_context; - // [format.fmt.string], class template basic_format_string template<typename _CharT, typename... _Args> struct basic_format_string; @@ -178,7 +176,7 @@ namespace __format // [format.formatter], formatter /// The primary template of std::formatter is disabled. - template<typename _Tp, typename _CharT = char> + template<typename _Tp, typename _CharT> struct formatter { formatter() = delete; // No std::formatter specialization for this type. @@ -923,14 +921,6 @@ namespace __format bool _M_hasval = false; }; -#ifdef _GLIBCXX_USE_WCHAR_T - template<typename _CharT> - concept __char = same_as<_CharT, char> || same_as<_CharT, wchar_t>; -#else - template<typename _CharT> - concept __char = same_as<_CharT, char>; -#endif - template<__char _CharT> struct __formatter_str { @@ -1277,12 +1267,26 @@ namespace __format _M_spec); } + [[__gnu__::__always_inline__]] + static size_t + _S_character_width(_CharT __c) + { + // N.B. single byte cannot encode charcter of width greater than 1 + if constexpr (sizeof(_CharT) > 1u && + __unicode::__literal_encoding_is_unicode<_CharT>()) + return __unicode::__field_width(__c); + else + return 1u; + } + template<typename _Out> typename basic_format_context<_Out, _CharT>::iterator _M_format_character(_CharT __c, basic_format_context<_Out, _CharT>& __fc) const { - return __format::__write_padded_as_spec({&__c, 1u}, 1, __fc, _M_spec); + return __format::__write_padded_as_spec({&__c, 1u}, + _S_character_width(__c), + __fc, _M_spec); } template<typename _Int> diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index d3deb7b..2e69af1 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -2534,7 +2534,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return [&]<size_t... _Inds>(index_sequence<_Inds...>) { // Fold == over the tuples until non-equal elements are found. - return ((std::get<_Inds>(__t) == std::get<_Inds>(__u)) && ...); + return (bool(std::get<_Inds>(__t) == std::get<_Inds>(__u)) && ...); }(index_sequence_for<_Tps...>{}); } diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector index 0f04334..8bb2543 100644 --- a/libstdc++-v3/include/std/vector +++ b/libstdc++-v3/include/std/vector @@ -157,4 +157,36 @@ _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // __cpp_lib_erase_if +#ifdef __glibcxx_format_ranges // C++ >= 20 && HOSTED +#include <bits/formatfwd.h> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + // Standard does not constrain accepted _CharT and declares it as formatter + // of Tp that statisfies is-vector-bool-reference<T>, + template<__format::__char _CharT> + struct formatter<_GLIBCXX_STD_C::_Bit_reference, _CharT> + { + // Standard declares this as template accepting unconstrained + // ParseContext type. + constexpr typename basic_format_parse_context<_CharT>::iterator + parse(basic_format_parse_context<_CharT>& __pc) + { return _M_f.template _M_parse<bool>(__pc); } + + // Standard declares this as template accepting unconstrained + // FormatContext type. + template<typename _Out> + typename basic_format_context<_Out, _CharT>::iterator + format(const _GLIBCXX_STD_C::_Bit_reference& __u, + basic_format_context<_Out, _CharT>& __fc) const + { return _M_f.format(static_cast<bool>(__u), __fc); } + + private: + __format::__formatter_int<_CharT> _M_f; + }; +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // __glibcxx_format_ranges + #endif /* _GLIBCXX_VECTOR */ diff --git a/libstdc++-v3/src/c++11/string-inst.cc b/libstdc++-v3/src/c++11/string-inst.cc index a160238..c486479 100644 --- a/libstdc++-v3/src/c++11/string-inst.cc +++ b/libstdc++-v3/src/c++11/string-inst.cc @@ -91,6 +91,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void S::_M_construct(const C*, const C*, forward_iterator_tag); + template + void + S::_M_construct<false>(const C*, size_t); + + template + void + S::_M_construct<true>(const C*, size_t); + #else // !_GLIBCXX_USE_CXX11_ABI template diff --git a/libstdc++-v3/testsuite/17_intro/shared_with_static_deps.cc b/libstdc++-v3/testsuite/17_intro/shared_with_static_deps.cc index 9491bbc..a84c110 100644 --- a/libstdc++-v3/testsuite/17_intro/shared_with_static_deps.cc +++ b/libstdc++-v3/testsuite/17_intro/shared_with_static_deps.cc @@ -1,5 +1,5 @@ // { dg-do link } -// { dg-require-static-libstdcxx } +// { dg-require-static-libstdcxx "" } // { dg-require-sharedlib "" } // { dg-require-effective-target fpic } // { dg-options "-shared -fPIC -static-libgcc -static-libstdc++" } diff --git a/libstdc++-v3/testsuite/17_intro/static.cc b/libstdc++-v3/testsuite/17_intro/static.cc index ab0cf27..26b34c8 100644 --- a/libstdc++-v3/testsuite/17_intro/static.cc +++ b/libstdc++-v3/testsuite/17_intro/static.cc @@ -1,5 +1,5 @@ // { dg-do run { target c++11 } } -// { dg-require-static-libstdcxx } +// { dg-require-static-libstdcxx "" } // { dg-options "-static-libstdc++" } // Copyright (C) 2012-2025 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/18_support/type_info/110572.cc b/libstdc++-v3/testsuite/18_support/type_info/110572.cc index f727653..5a05078 100644 --- a/libstdc++-v3/testsuite/18_support/type_info/110572.cc +++ b/libstdc++-v3/testsuite/18_support/type_info/110572.cc @@ -1,6 +1,6 @@ // { dg-options "-static-libstdc++" } // { dg-do link } -// { dg-require-static-libstdcxx } +// { dg-require-static-libstdcxx "" } // { dg-require-cpp-feature-test __cpp_rtti } #include <typeinfo> diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc index af3b733..5dff0da 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc @@ -178,12 +178,40 @@ test03() void test_pr101587() { - short in[1]; + short in[1]{}; __gnu_test::test_contiguous_range r(in); // difference_type is integer-like long out[1]; std::span<long> o(out); // difference_type is ptrdiff_t ranges::uninitialized_copy(r, o); ranges::uninitialized_copy_n(ranges::begin(r), 0, o.begin(), o.end()); + + // iterator that has an integer-like class type for difference_type + struct Iter + { + using value_type = long; + using difference_type = std::ranges::__detail::__max_diff_type; + + long& operator*() const { return *p; } + + Iter& operator++() { ++p; return *this; } + Iter operator++(int) { return Iter{p++}; } + + difference_type operator-(Iter i) const { return p - i.p; } + bool operator==(const Iter&) const = default; + + long* p = nullptr; + }; + static_assert(std::sized_sentinel_for<Iter, Iter>); + + std::ranges::subrange<Iter> rmax(Iter{out+0}, Iter{out+1}); + // Check with integer-like class type for output range: + std::ranges::uninitialized_copy(in, rmax); + std::ranges::uninitialized_copy_n(in+0, 1, rmax.begin(), rmax.end()); + + int to[1]; + // And for input range: + std::ranges::uninitialized_copy(rmax, to); + std::ranges::uninitialized_copy_n(rmax.begin(), 1, to+0, to+1); } int diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc index fe82d1f1..3e81244 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc @@ -188,12 +188,39 @@ test03() void test_pr101587() { - short in[1]; + short in[1]{}; __gnu_test::test_contiguous_range r(in); // difference_type is integer-like long out[1]; std::span<long> o(out); // difference_type is ptrdiff_t ranges::uninitialized_move(r, o); ranges::uninitialized_move_n(ranges::begin(r), 0, o.begin(), o.end()); + + struct Iter + { + using value_type = long; + using difference_type = std::ranges::__detail::__max_diff_type; + + long& operator*() const { return *p; } + + Iter& operator++() { ++p; return *this; } + Iter operator++(int) { return Iter{p++}; } + + difference_type operator-(Iter i) const { return p - i.p; } + bool operator==(const Iter&) const = default; + + long* p = nullptr; + }; + static_assert(std::sized_sentinel_for<Iter, Iter>); + + std::ranges::subrange<Iter> rmax(Iter{out+0}, Iter{out+1}); + // Check with integer-like class type for output range: + std::ranges::uninitialized_move(in, rmax); + std::ranges::uninitialized_move_n(in+0, 1, rmax.begin(), rmax.end()); + + int to[1]; + // And for input range: + std::ranges::uninitialized_copy(rmax, to); + std::ranges::uninitialized_copy_n(rmax.begin(), 1, to+0, to+1); } int diff --git a/libstdc++-v3/testsuite/20_util/to_chars/4.cc b/libstdc++-v3/testsuite/20_util/to_chars/4.cc index 3d76d56..65abfaa 100644 --- a/libstdc++-v3/testsuite/20_util/to_chars/4.cc +++ b/libstdc++-v3/testsuite/20_util/to_chars/4.cc @@ -17,7 +17,7 @@ // { dg-do link { target c++17 } } // { dg-require-effective-target ieee_floats } -// { dg-require-static-libstdcxx } +// { dg-require-static-libstdcxx "" } // { dg-additional-options "-static-libstdc++" } // Verify the Ryu symbol generic_to_chars doesn't inadvertently leak into diff --git a/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/119545.cc b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/119545.cc new file mode 100644 index 0000000..3a65ef5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/119545.cc @@ -0,0 +1,24 @@ +// { dg-do compile { target c++11 } } +// Bug libstdc++/119545 +// tuple::operator==()'s help lambda does not specify return type as bool + +#include <tuple> + +void +test_pr119545() +{ + struct Bool { + Bool() = default; + Bool(const Bool&) = delete; + operator bool() const { return true; } + }; + + static Bool b; + + struct Object { + const Bool& operator==(const Object&) const { return b; } + }; + + std::tuple<Object> t; + (void) (t == t); +} diff --git a/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc b/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc index dc3cecd..7d9a33c 100644 --- a/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc +++ b/libstdc++-v3/testsuite/23_containers/flat_multiset/1.cc @@ -214,6 +214,27 @@ void test07() #endif } +void +test08() +{ + // PR libstdc++/119620 -- flat_set::emplace always constructs element on the stack + static int copy_counter; + struct A { + A() { } + A(const A&) { ++copy_counter; } + A& operator=(const A&) { ++copy_counter; return *this; } + auto operator<=>(const A&) const = default; + }; + std::vector<A> v; + v.reserve(2); + std::flat_multiset<A> s(std::move(v)); + A a; + s.emplace(a); + VERIFY( copy_counter == 1 ); + s.emplace(a); + VERIFY( copy_counter == 2 ); +} + int main() { @@ -225,4 +246,5 @@ main() test05(); test06(); test07(); + test08(); } diff --git a/libstdc++-v3/testsuite/23_containers/flat_set/1.cc b/libstdc++-v3/testsuite/23_containers/flat_set/1.cc index 90f5855..ed24fab 100644 --- a/libstdc++-v3/testsuite/23_containers/flat_set/1.cc +++ b/libstdc++-v3/testsuite/23_containers/flat_set/1.cc @@ -229,6 +229,25 @@ void test07() #endif } +void +test08() +{ + // PR libstdc++/119620 -- flat_set::emplace always constructs element on the stack + static int copy_counter; + struct A { + A() { } + A(const A&) { ++copy_counter; } + A& operator=(const A&) { ++copy_counter; return *this; } + auto operator<=>(const A&) const = default; + }; + std::flat_set<A> s; + A a; + s.emplace(a); + VERIFY( copy_counter == 1 ); + s.emplace(a); + VERIFY( copy_counter == 1 ); +} + int main() { @@ -240,4 +259,5 @@ main() test05(); test06(); test07(); + test08(); } diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/110498.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/110498.cc new file mode 100644 index 0000000..f848edc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/110498.cc @@ -0,0 +1,18 @@ +// { dg-options "-O3 -Werror=array-bounds -fno-assume-sane-operators-new-delete" } +// { dg-do compile } + +// Bug libstdc++/110498 +// Spurious warnings stringop-overflow and array-bounds copying data as bytes +// into vector::reserve + +#include <vector> + +void f(std::vector<bool>& v) +{ + // Warning emitted when set to any number in the range [1,64]. + const std::size_t reserve_size = 30; + + v.reserve(reserve_size); + v.push_back(0); +} + diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/114758.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/114758.cc new file mode 100644 index 0000000..c56d50a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/114758.cc @@ -0,0 +1,12 @@ +// { dg-options "-O3 -Werror=stringop-overread -fno-assume-sane-operators-new-delete" } +// { dg-do compile } + +// Bug libstdc++/114758 The layout of a std::vector<bool> reports a warning + +#include <vector> + +void pr114758(std::vector<bool>& v) +{ + v.resize(3); + v = std::vector<bool>(3, false); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/format.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/format.cc new file mode 100644 index 0000000..16f6e86 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/format.cc @@ -0,0 +1,67 @@ +// { dg-do run { target c++23 } } +// { dg-timeout-factor 2 } + +#include <format> +#include <vector> +#include <chrono> // For _Widen +#include <testsuite_hooks.h> + +static_assert(!std::formattable<std::vector<bool>::reference, int>); +static_assert(!std::formattable<std::vector<bool>::reference, char32_t>); + +template<typename... Args> +bool +is_format_string_for(const char* str, Args&&... args) +{ + try { + (void) std::vformat(str, std::make_format_args(args...)); + return true; + } catch (const std::format_error&) { + return false; + } +} + +#define WIDEN_(C, S) ::std::chrono::__detail::_Widen<C>(S, L##S) +#define WIDEN(S) WIDEN_(_CharT, S) + +void +test_format_string() +{ + std::vector<bool> v(1, true); + VERIFY( !is_format_string_for("{:?}", v[0]) ); + VERIFY( !is_format_string_for("{:P}", v[0]) ); + + // width needs to be integer type + VERIFY( !is_format_string_for("{:{}}", v[0], 1.0f) ); +} + +template<typename _CharT> +void +test_output() +{ + std::basic_string<_CharT> res; + size_t size = 0; + std::vector<bool> v{true, false}; + + res = std::format(WIDEN("{}"), v[0]); + VERIFY( res == WIDEN("true") ); + + res = std::format(WIDEN("{:s}"), v[1]); + VERIFY( res == WIDEN("false") ); + + res = std::format(WIDEN("{:d} {:#B} {:#o} {:#x}"), v[0], v[1], v[0], v[1]); + VERIFY( res == WIDEN("1 0B0 01 0x0") ); + + res = std::format(WIDEN("{:{}}"), v[0], 6); + VERIFY( res == WIDEN("true ") ); + + res = std::format(WIDEN("{:=^#7X}"), v[1]); + VERIFY( res == WIDEN("==0X0==") ); +} + +int main() +{ + test_format_string(); + test_output<char>(); + test_output<wchar_t>(); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/114945.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/114945.cc new file mode 100644 index 0000000..daafc59 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/114945.cc @@ -0,0 +1,36 @@ +// { dg-options "-O2 -Werror=stringop-overflow -Werror=array-bounds" } +// { dg-do compile { target c++11 } } + +// Bug libstdc++/114945 +// Sporadic std::vector::resize() -Wstringop-overflow or -Warray-bounds warning + +#include <stdint.h> +#include <vector> +template <typename a> struct b { + void resize(std::size_t c) { d.resize(c); } + template <typename e> void f(a, e); + std::vector<char> d; +}; +#include <regex> +std::regex g; +uint64_t h; +uint32_t i; +struct s { + enum class j : size_t; + void k(); + using l = b<j>; + std::vector<l> m; +}; +enum class s::j : size_t { n }; +void o() { g = ""; } +void s::k() { + l p; + auto q = uint32_t(), r = uint32_t(); + if (h) + r = i; + b<size_t> t; + if (q || r) + p.f(j::n, 5); + t.resize(4); + m.push_back(p); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc new file mode 100644 index 0000000..e6027a6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc @@ -0,0 +1,17 @@ +// { dg-options "-O3 -Werror=stringop-overflow" } +// { dg-do compile } + +// PR libstdc++/117983 +// -Wstringop-overflow false positive for __builtin_memmove from vector::insert + +#include <vector> + +typedef std::vector<unsigned char> bytes; + +void push(bytes chunk, bytes& data) { + if (data.empty()) { + data.swap(chunk); + } else { + data.insert(data.end(), chunk.begin(), chunk.end()); + } +} diff --git a/libstdc++-v3/testsuite/lib/prune.exp b/libstdc++-v3/testsuite/lib/prune.exp index 416e851..a9a2993 100644 --- a/libstdc++-v3/testsuite/lib/prune.exp +++ b/libstdc++-v3/testsuite/lib/prune.exp @@ -77,6 +77,9 @@ proc libstdc++-dg-prune { system text } { # Ignore harmless warnings from Xcode 4+. regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind for\[^\n\]*" $text "" text + # Ignore duplicate path warnings from Xcode 16+. + regsub -all "(^|\n)\[^\n\]*ld: warning: duplicate -rpath\[^\n\]*" $text "" text + # Ignore dsymutil warning (tool bug is actually in the linker) regsub -all "(^|\n)\[^\n\]*could not find object file symbol for symbol\[^\n\]*" $text "" text diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc b/libstdc++-v3/testsuite/std/format/functions/format.cc index 7fc4201..000f267 100644 --- a/libstdc++-v3/testsuite/std/format/functions/format.cc +++ b/libstdc++-v3/testsuite/std/format/functions/format.cc @@ -501,9 +501,14 @@ test_unicode() { // Similar to sC example in test_std_examples, but not from the standard. // Verify that the character "🤡" has estimated field width 2, - // rather than estimated field width equal to strlen("🤡"), which would be 4. + // rather than estimated field width equal to strlen("🤡"), which would be 4, + // or just width 1 for single character. std::string sC = std::format("{:*<3}", "🤡"); VERIFY( sC == "🤡*" ); + std::wstring wsC = std::format(L"{:*<3}", L"🤡"); + VERIFY( wsC == L"🤡*" ); + wsC = std::format(L"{:*<3}", L'🤡'); + VERIFY( wsC == L"🤡*" ); // Verify that "£" has estimated field width 1, not strlen("£") == 2. std::string sL = std::format("{:*<3}", "£"); diff --git a/libstdc++-v3/testsuite/std/time/format/pr119517.cc b/libstdc++-v3/testsuite/std/time/format/pr119517.cc new file mode 100644 index 0000000..37bff86 --- /dev/null +++ b/libstdc++-v3/testsuite/std/time/format/pr119517.cc @@ -0,0 +1,43 @@ +// { dg-do compile { target c++23 } } + +#include <chrono> +#include <format> + +static_assert( std::formattable<std::chrono::weekday, char> ); +static_assert( std::formattable<std::chrono::weekday, wchar_t> ); +static_assert( !std::formattable<std::chrono::weekday, char16_t> ); + +static_assert( std::formattable<std::chrono::sys_days, char> ); +static_assert( std::formattable<std::chrono::sys_days, wchar_t> ); +static_assert( !std::formattable<std::chrono::sys_days, char16_t> ); + +static_assert( !std::formattable<std::chrono::seconds, int> ); + +static_assert( !std::formattable<std::chrono::day, int> ); +static_assert( !std::formattable<std::chrono::month, int> ); +static_assert( !std::formattable<std::chrono::year, int> ); +static_assert( !std::formattable<std::chrono::weekday, int> ); +static_assert( !std::formattable<std::chrono::weekday_indexed, int> ); +static_assert( !std::formattable<std::chrono::weekday_last, int> ); +static_assert( !std::formattable<std::chrono::month_day, int> ); +static_assert( !std::formattable<std::chrono::month_day_last, int> ); +static_assert( !std::formattable<std::chrono::month_weekday, int> ); +static_assert( !std::formattable<std::chrono::month_weekday_last, int> ); +static_assert( !std::formattable<std::chrono::year_month_day, int> ); +static_assert( !std::formattable<std::chrono::year_month_day_last, int> ); +static_assert( !std::formattable<std::chrono::year_month_weekday, int> ); +static_assert( !std::formattable<std::chrono::year_month_weekday_last, int> ); +static_assert( !std::formattable<std::chrono::hh_mm_ss<std::chrono::seconds>, int> ); + +static_assert( !std::formattable<std::chrono::sys_seconds, int> ); +static_assert( !std::formattable<std::chrono::utc_seconds, int> ); +static_assert( !std::formattable<std::chrono::tai_seconds, int> ); +static_assert( !std::formattable<std::chrono::gps_seconds, int> ); +static_assert( !std::formattable<std::chrono::local_seconds, int> ); +static_assert( !std::formattable<std::chrono::file_time<std::chrono::seconds>, int> ); +#if _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI +static_assert( !std::formattable<std::chrono::zoned_seconds, int> ); + +static_assert( !std::formattable<std::chrono::sys_info, int> ); +static_assert( !std::formattable<std::chrono::local_info, int> ); +#endif diff --git a/libstdc++-v3/testsuite/std/time/tzdb_list/pr118811.cc b/libstdc++-v3/testsuite/std/time/tzdb_list/pr118811.cc index 3968be3..fe86602 100644 --- a/libstdc++-v3/testsuite/std/time/tzdb_list/pr118811.cc +++ b/libstdc++-v3/testsuite/std/time/tzdb_list/pr118811.cc @@ -1,7 +1,7 @@ // { dg-do run { target c++20 } } // { dg-require-effective-target tzdb } // { dg-require-effective-target cxx11_abi } -// { dg-require-static-libstdcxx } +// { dg-require-static-libstdcxx "" } // { dg-additional-options "-static-libstdc++" } #include <chrono> |