Skip to content

Commit

Permalink
libstdc++: Fix __cpp_lib_chrono for old std::string ABI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jwakely committed Jun 21, 2024
1 parent 510ce5e commit f906b10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions libstdc++-v3/include/bits/version.def
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ ftms = {
v = 201907;
cxxmin = 20;
hosted = yes;
cxx11abi = yes; // std::chrono::tzdb requires cxx11 std::string
};
values = {
v = 201611;
Expand Down
2 changes: 1 addition & 1 deletion libstdc++-v3/include/bits/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@
#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
Expand Down
11 changes: 9 additions & 2 deletions libstdc++-v3/testsuite/std/time/syn_c++20.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@

#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

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f906b10

Please sign in to comment.