[gcc r16-8583] libstdc++: Define __cpp_lib_replaceable_contract_violation_handler.
Tomasz Kaminski
tkaminsk@gcc.gnu.org
Mon Apr 13 11:07:02 GMT 2026
https://gcc.gnu.org/g:8beabc8851568da82781ed2a47ef0a08f585fddd
commit r16-8583-g8beabc8851568da82781ed2a47ef0a08f585fddd
Author: Tomasz Kamiński <tkaminsk@redhat.com>
Date: Wed Apr 8 15:46:28 2026 +0200
libstdc++: Define __cpp_lib_replaceable_contract_violation_handler.
This implements P3886R0: Wording for AT1-057, by defining the
__cpp_lib_replaceable_contract_violation_handler. The macro is defined
only if contracts are supported (i.e. under same conditions as
__cpp_lib_contracts).
GCC supports providing custom violation handler by providing an separate
defintion of handle_contract_violation. This is supported on the targets
that uses ELF format, so the macro is defined for with non-zero value
for them.
libstdc++-v3/ChangeLog:
* include/bits/version.def (replaceable_contract_violation_handler)
[(__cplusplus > 202302L) && (__cpp_contracts >= 202502L)]:
Define to 202603 for ELF targets, and 0 otherwise.
* include/bits/version.h: Regenerate.
* include/std/contracts: Define
__cpp_lib_replaceable_contract_violation_handler.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Diff:
---
libstdc++-v3/include/bits/version.def | 15 +++++++++++++++
libstdc++-v3/include/bits/version.h | 15 +++++++++++++++
libstdc++-v3/include/std/contracts | 1 +
3 files changed, 31 insertions(+)
diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
index 3b4a0d4fdc05..b88d9c3483f8 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -2349,6 +2349,21 @@ ftms = {
};
};
+ftms = {
+ name = replaceable_contract_violation_handler;
+ values = {
+ v = 202603;
+ cxxmin = 26;
+ extra_cond = "__cpp_contracts >= 202502L "
+ "&& __ELF__";
+ };
+ values = {
+ v = 0;
+ cxxmin = 26;
+ extra_cond = "__cpp_contracts >= 202502L";
+ };
+};
+
ftms = {
name = simd;
values = {
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 59719b4f8116..24ec0175e1e4 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -2616,6 +2616,21 @@
#endif /* !defined(__cpp_lib_contracts) */
#undef __glibcxx_want_contracts
+#if !defined(__cpp_lib_replaceable_contract_violation_handler)
+# if (__cplusplus > 202302L) && (__cpp_contracts >= 202502L && __ELF__)
+# define __glibcxx_replaceable_contract_violation_handler 202603L
+# if defined(__glibcxx_want_all) || defined(__glibcxx_want_replaceable_contract_violation_handler)
+# define __cpp_lib_replaceable_contract_violation_handler 202603L
+# endif
+# elif (__cplusplus > 202302L) && (__cpp_contracts >= 202502L)
+# define __glibcxx_replaceable_contract_violation_handler 0L
+# if defined(__glibcxx_want_all) || defined(__glibcxx_want_replaceable_contract_violation_handler)
+# define __cpp_lib_replaceable_contract_violation_handler 0L
+# endif
+# endif
+#endif /* !defined(__cpp_lib_replaceable_contract_violation_handler) */
+#undef __glibcxx_want_replaceable_contract_violation_handler
+
#if !defined(__cpp_lib_simd)
# if (__cplusplus > 202302L) && _GLIBCXX_HOSTED && (__cpp_structured_bindings >= 202411L && __cpp_expansion_statements >= 202411L && __SSE2__)
# define __glibcxx_simd 202506L
diff --git a/libstdc++-v3/include/std/contracts b/libstdc++-v3/include/std/contracts
index c1fe54750af9..a0575fbefd93 100644
--- a/libstdc++-v3/include/std/contracts
+++ b/libstdc++-v3/include/std/contracts
@@ -33,6 +33,7 @@
#pragma GCC system_header
#define __glibcxx_want_contracts
+#define __glibcxx_want_replaceable_contract_violation_handler
#include <bits/version.h>
#ifdef __cpp_lib_contracts
More information about the Libstdc++-cvs
mailing list