]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix __cpp_lib_chrono for old std::string ABI
authorJonathan Wakely <jwakely@redhat.com>
Thu, 20 Jun 2024 12:28:08 +0000 (13:28 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 21 Jun 2024 09:10:10 +0000 (10:10 +0100)
The <chrono> header is incomplete for the old std::string ABI, because
std::chrono::tzdb is only defined for the new ABI. The feature test
macro advertising full C++20 support should not be defined for the old
ABI.

libstdc++-v3/ChangeLog:

* include/bits/version.def (chrono): Add cxx11abi = yes.
* include/bits/version.h: Regenerate.
* testsuite/std/time/syn_c++20.cc: Adjust expected value for
the feature test macro.

libstdc++-v3/include/bits/version.def
libstdc++-v3/include/bits/version.h
libstdc++-v3/testsuite/std/time/syn_c++20.cc

index 683b967d54b137e29ea60cd2ce10470cdf56eab1..42cdef2f5265ca721b36f2944b8234d9cd71ea46 100644 (file)
@@ -574,6 +574,7 @@ ftms = {
     v = 201907;
     cxxmin = 20;
     hosted = yes;
+    cxx11abi = yes; // std::chrono::tzdb requires cxx11 std::string
   };
   values = {
     v = 201611;
index 4850041c0a3e7107afd392f6ffbf14b20bc57e70..1eaf3733bc2a811d121dac9f54c187913f01032c 100644 (file)
 #undef __glibcxx_want_boyer_moore_searcher
 
 #if !defined(__cpp_lib_chrono)
-# if (__cplusplus >= 202002L) && _GLIBCXX_HOSTED
+# if (__cplusplus >= 202002L) && _GLIBCXX_USE_CXX11_ABI && _GLIBCXX_HOSTED
 #  define __glibcxx_chrono 201907L
 #  if defined(__glibcxx_want_all) || defined(__glibcxx_want_chrono)
 #   define __cpp_lib_chrono 201907L
index f0b86199e9dbf23bf2fedb24c5a901e170f03928..4a527262e9d829168c0bbb4649ef4c8105f62fbd 100644 (file)
 
 #include <chrono>
 
+// std::chrono::tzdb is not defined for the old std::string ABI.
+#if _GLIBCXX_USE_CXX_ABI
+# define EXPECTED_VALUE 201907L
+#else
+# define EXPECTED_VALUE 201611L
+#endif
+
 #ifndef __cpp_lib_chrono
 # error "Feature test macro for chrono is missing in <chrono>"
-#elif __cpp_lib_chrono < 201907L
+#elif __cpp_lib_chrono < EXPECTED_VALUE
 # error "Feature test macro for chrono has wrong value in <chrono>"
 #endif
 
@@ -94,7 +101,7 @@ namespace __gnu_test
   using std::chrono::make12;
   using std::chrono::make24;
 
-#if _GLIBCXX_USE_CXX11_ABI
+#if __cpp_lib_chrono >= 201803L
   using std::chrono::tzdb;
   using std::chrono::tzdb_list;
   using std::chrono::get_tzdb;