From 8beabc8851568da82781ed2a47ef0a08f585fddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kami=C5=84ski?= Date: Wed, 8 Apr 2026 15:46:28 +0200 Subject: [PATCH] libstdc++: Define __cpp_lib_replaceable_contract_violation_handler. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Tomasz KamiƄski --- 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 3b4a0d4fdc0..b88d9c3483f 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 59719b4f811..24ec0175e1e 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 c1fe54750af..a0575fbefd9 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 #ifdef __cpp_lib_contracts