Skip to content

Commit 278eb0a

Browse files
committed
libstdc++: Make __cpp_lib_constexpr_exceptions depend on cxx11 ABI
The COW std::string is not constexpr, so the <stdexcept> exception classes can't be constexpr either when they're defined in terms of the COW string. While constexpr exceptions for <typeinfo>, <new>, and <exception> classes would work, __cpp_constexpr_exceptions >= 202411L implies that everything including <stdexcept> should work. So when we can't support it fully, we shouldn't announce it. libstdc++-v3/ChangeLog: * include/bits/version.def (constexpr_exceptions): Add cxx11abi=yes. * include/bits/version.h: Regenerate. * testsuite/18_support/exception/version.cc: Require effectiove target cxx11_abi. * testsuite/18_support/exception_ptr/exception_ptr_cast.cc: Only check for constexpr support in cxx11 ABI. * testsuite/19_diagnostics/headers/stdexcept/version.cc: Require effective target cxx11_abi. * testsuite/19_diagnostics/logic_error/constexpr.cc: Likewise. * testsuite/19_diagnostics/runtime_error/constexpr.cc: Likewise. * testsuite/20_util/expected/version.cc: Only check for __cpp_lib_constexpr_exceptions macro for cxx11 ABI. * testsuite/20_util/optional/version.cc: Likewise. * testsuite/20_util/variant/version.cc: Likewise. Reviewed-by: Jakub Jelinek <[email protected]>
1 parent 1208456 commit 278eb0a

File tree

10 files changed

+16
-5
lines changed

10 files changed

+16
-5
lines changed

libstdc++-v3/include/bits/version.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,7 @@ ftms = {
22332233
v = 202502;
22342234
cxxmin = 26;
22352235
extra_cond = "__cpp_constexpr_exceptions >= 202411L";
2236+
cxx11abi = yes;
22362237
};
22372238
};
22382239

libstdc++-v3/include/bits/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2497,7 +2497,7 @@
24972497
#undef __glibcxx_want_bitset
24982498

24992499
#if !defined(__cpp_lib_constexpr_exceptions)
2500-
# if (__cplusplus > 202302L) && (__cpp_constexpr_exceptions >= 202411L)
2500+
# if (__cplusplus > 202302L) && _GLIBCXX_USE_CXX11_ABI && (__cpp_constexpr_exceptions >= 202411L)
25012501
# define __glibcxx_constexpr_exceptions 202502L
25022502
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_constexpr_exceptions)
25032503
# define __cpp_lib_constexpr_exceptions 202502L

libstdc++-v3/testsuite/18_support/exception/version.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// { dg-do preprocess { target c++26 } }
22
// { dg-add-options no_pch }
3+
// { dg-require-effective-target cxx11_abi }
34

45
#include <exception>
56

libstdc++-v3/testsuite/18_support/exception_ptr/exception_ptr_cast.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ constexpr bool test01(bool x)
7878
return true;
7979
}
8080

81+
#if _GLIBCXX_USE_CXX11_ABI
8182
static_assert(test01(false));
83+
#endif
8284

8385
int main()
8486
{

libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/version.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// { dg-do preprocess { target c++26 } }
22
// { dg-add-options no_pch }
3+
// { dg-require-effective-target cxx11_abi }
34

45
#include <stdexcept>
56

libstdc++-v3/testsuite/19_diagnostics/logic_error/constexpr.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// { dg-do compile { target c++26 } }
2+
// { dg-require-effective-target cxx11_abi }
23

34
#include <string>
45
#include <stdexcept>

libstdc++-v3/testsuite/19_diagnostics/runtime_error/constexpr.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// { dg-do compile { target c++26 } }
2+
// { dg-require-effective-target cxx11_abi }
23

34
#include <string>
45
#include <stdexcept>

libstdc++-v3/testsuite/20_util/expected/version.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# error "Feature-test macro for freestanding expected has wrong value in <version>"
1616
#endif
1717

18-
#if __cplusplus > 202302L
18+
#if __cplusplus > 202302L && _GLIBCXX_USE_CXX11_ABI
1919
# ifndef __cpp_lib_constexpr_exceptions
2020
# error "Feature test macro for constexpr_exceptions is missing in <version>"
2121
# elif __cpp_lib_constexpr_exceptions < 202502L
@@ -40,7 +40,7 @@
4040
# error "Feature-test macro for freestanding expected has wrong value in <expected>"
4141
#endif
4242

43-
#if __cplusplus > 202302L
43+
#if __cplusplus > 202302L && _GLIBCXX_USE_CXX11_ABI
4444
# ifndef __cpp_lib_constexpr_exceptions
4545
# error "Feature test macro for constexpr_exceptions is missing in <expected>"
4646
# elif __cpp_lib_constexpr_exceptions < 202502L

libstdc++-v3/testsuite/20_util/optional/version.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
# error "Feature test macro for optional range support has wrong value for C++26 in <version>"
3131
# endif
3232

33+
# if _GLIBCXX_USE_CXX11_ABI
3334
# ifndef __cpp_lib_constexpr_exceptions
3435
# error "Feature test macro for constexpr_exceptions is missing in <version>"
3536
# elif __cpp_lib_constexpr_exceptions < 202502L
3637
# error "Feature test macro for constexpr_exceptions has wrong value in <version>"
3738
# endif
39+
# endif
3840
#endif
3941

4042
#undef __cpp_lib_optional
@@ -59,9 +61,11 @@
5961
# error "Feature test macro for optional range support has wrong value for C++26 in <optional>"
6062
# endif
6163

64+
# if _GLIBCXX_USE_CXX11_ABI
6265
# ifndef __cpp_lib_constexpr_exceptions
6366
# error "Feature test macro for constexpr_exceptions is missing in <optional>"
6467
# elif __cpp_lib_constexpr_exceptions < 202502L
6568
# error "Feature test macro for constexpr_exceptions has wrong value in <optional>"
6669
# endif
70+
# endif
6771
#endif

libstdc++-v3/testsuite/20_util/variant/version.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#endif
2020
#endif
2121

22-
#if __cplusplus > 202302L
22+
#if __cplusplus > 202302L && _GLIBCXX_USE_CXX11_ABI
2323
#ifndef __cpp_lib_constexpr_exceptions
2424
# error "Feature test macro for constexpr_exceptions is missing in <version>"
2525
#elif __cpp_lib_constexpr_exceptions < 202502L
@@ -40,7 +40,7 @@
4040
#endif
4141
#endif
4242

43-
#if __cplusplus > 202302L
43+
#if __cplusplus > 202302L && _GLIBCXX_USE_CXX11_ABI
4444
#ifndef __cpp_lib_constexpr_exceptions
4545
# error "Feature test macro for constexpr_exceptions is missing in <variant>"
4646
#elif __cpp_lib_constexpr_exceptions < 202502L

0 commit comments

Comments
 (0)