{"id":2220970,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2220970/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260408135939.266955-1-tkaminsk@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260408135939.266955-1-tkaminsk@redhat.com>","date":"2026-04-08T13:59:08","name":"libstdc++: Defined __cpp_lib_replaceable_contract_violation_handler.","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"dc7b53d506df2ffabbd2bd79781ecaa9205ca6de","submitter":{"id":90409,"url":"http://patchwork.ozlabs.org/api/1.1/people/90409/?format=json","name":"Tomasz Kamiński","email":"tkaminsk@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260408135939.266955-1-tkaminsk@redhat.com/mbox/","series":[{"id":499145,"url":"http://patchwork.ozlabs.org/api/1.1/series/499145/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=499145","date":"2026-04-08T13:59:08","name":"libstdc++: Defined __cpp_lib_replaceable_contract_violation_handler.","version":1,"mbox":"http://patchwork.ozlabs.org/series/499145/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2220970/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2220970/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=g/ePBHdJ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=g/ePBHdJ","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frPrR4LhZz1xv0\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 00:01:59 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id C0C8C4BA2E1B\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  8 Apr 2026 14:01:57 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 9C5244BA2E17\n for <gcc-patches@gcc.gnu.org>; Wed,  8 Apr 2026 13:59:44 +0000 (GMT)","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-49rDlLD1PPK3NHlA-OLnYA-1; Wed,\n 08 Apr 2026 09:59:42 -0400","from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id A387A1956056; Wed,  8 Apr 2026 13:59:41 +0000 (UTC)","from localhost (unknown [10.44.50.40])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 106D919560A6; Wed,  8 Apr 2026 13:59:40 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org C0C8C4BA2E1B","OpenDKIM Filter v2.11.0 sourceware.org 9C5244BA2E17"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 9C5244BA2E17","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 9C5244BA2E17","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775656784; cv=none;\n b=dc8tKMZcDRtYIXj8Yxp3GAGpNZkRHtoOQ1or5kWWqT6lU+z8tQursEtcE8hmWClLHOmZk2/KV+Tjoc48xjgNG0sX65pjSQQJh57hz2Uams1la2ZHJHeiXIxKnh1ETpOxcaH40VkZxh17cPnoLi1anhYSIINEOOivzym3i0POogI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775656784; c=relaxed/simple;\n bh=z/P2JrhV3K9AnBBmcmLBS5KUC3U6juyEb1STO03+wmE=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=fA25ftyWTrLbdffbM3nDULqGs+6TaaKA1IKDYh3RmNulrtX1QVh8DsfAMQNAEyRFnzzunIQXrZvn64AutloxxK6ngS1JKX/vXTmAXvlK1zYz/bayp1nRRL3Mgcv9Dp5EpNClgbyGMnSbE8W7w+qPHPMq/hwowz+PejYHrlrpaFE=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775656784;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=oF0TBWpnw1/pN1b6YeLh+f3clE7URADMSnDdm81+pCY=;\n b=g/ePBHdJNnISlyZApisqLLKlavIy6EqCqy1dAoOCpeO/s6nHL3DTX4kBm2G64y2hvb5pqJ\n pN3ZUXKU+Vf2OsrjD9tglyL2yWu/ZgVNDKOJAa6IrjHwMtGSSDi1gtM3TMKbU5KiQ9QtJ9\n bQo1yxPOIpiTw03XUL8A5HfqTwU4t8s=","X-MC-Unique":"49rDlLD1PPK3NHlA-OLnYA-1","X-Mimecast-MFC-AGG-ID":"49rDlLD1PPK3NHlA-OLnYA_1775656781","From":"=?utf-8?q?Tomasz_Kami=C5=84ski?= <tkaminsk@redhat.com>","To":"libstdc++@gcc.gnu.org,\n\tgcc-patches@gcc.gnu.org","Subject":"[PATCH] libstdc++: Defined\n __cpp_lib_replaceable_contract_violation_handler.","Date":"Wed,  8 Apr 2026 15:59:08 +0200","Message-ID":"<20260408135939.266955-1-tkaminsk@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.12","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"SVEBkjKJEJmIvI4D-jTMEM3aA70DWBbY1otg0jnR2_w_1775656781","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"This implements P3886R0: Wording for AT1-057, by defining the\n__cpp_lib_replaceable_contract_violation_handler. The macro is defined\nonly if contracts are supported (i.e. under same conditions as\n__cpp_lib_contracts).\n\nGCC supports providing custom violation handler by providing an separate\ndefintion of handle_contract_violation. This is supported on the targets\nthat uses ELF format, so the macro is defined for with non-zero value\nfor them.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/version.def (replaceable_contract_violation_handler)\n\t[(__cplusplus > 202302L) && (__cpp_contracts >= 202502L)]:\n\tDefine to 202603 for ELF targets, and 0 otherwise.\n\t* include/bits/version.h: Regenerate.\n\t* include/std/contracts: Define\n\t__cpp_lib_replaceable_contract_violation_handler.\n---\nFrom the discussion with Jason, this for sure is supported for ELF\ntargets. We were not sure regarding Darwin, but we could always expand\nthe set of targets where macro is defined.\n\nOK for trunk?\n\n libstdc++-v3/include/bits/version.def | 15 +++++++++++++++\n libstdc++-v3/include/bits/version.h   | 15 +++++++++++++++\n libstdc++-v3/include/std/contracts    |  1 +\n 3 files changed, 31 insertions(+)","diff":"diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def\nindex cfb90533ce4..65a1d6d2660 100644\n--- a/libstdc++-v3/include/bits/version.def\n+++ b/libstdc++-v3/include/bits/version.def\n@@ -2351,6 +2351,21 @@ ftms = {\n   };\n };\n \n+ftms = {\n+  name = replaceable_contract_violation_handler;\n+  values = {\n+    v = 202603;\n+    cxxmin = 26;\n+    extra_cond = \"__cpp_contracts >= 202502L \"\n+    \"&& __ELF__\";\n+  };\n+  values = {\n+    v = 0;\n+    cxxmin = 26;\n+    extra_cond = \"__cpp_contracts >= 202502L\";\n+  };\n+};\n+\n ftms = {\n   name = simd;\n   values = {\ndiff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h\nindex 22dd31b9d32..4059a8a767b 100644\n--- a/libstdc++-v3/include/bits/version.h\n+++ b/libstdc++-v3/include/bits/version.h\n@@ -2626,6 +2626,21 @@\n #endif /* !defined(__cpp_lib_contracts) */\n #undef __glibcxx_want_contracts\n \n+#if !defined(__cpp_lib_replaceable_contract_violation_handler)\n+# if (__cplusplus >  202302L) && (__cpp_contracts >= 202502L && __ELF__)\n+#  define __glibcxx_replaceable_contract_violation_handler 202603L\n+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_replaceable_contract_violation_handler)\n+#   define __cpp_lib_replaceable_contract_violation_handler 202603L\n+#  endif\n+# elif (__cplusplus >  202302L) && (__cpp_contracts >= 202502L)\n+#  define __glibcxx_replaceable_contract_violation_handler 0L\n+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_replaceable_contract_violation_handler)\n+#   define __cpp_lib_replaceable_contract_violation_handler 0L\n+#  endif\n+# endif\n+#endif /* !defined(__cpp_lib_replaceable_contract_violation_handler) */\n+#undef __glibcxx_want_replaceable_contract_violation_handler\n+\n #if !defined(__cpp_lib_simd)\n # if (__cplusplus >  202302L) && _GLIBCXX_HOSTED && (__cpp_structured_bindings >= 202411L && __cpp_expansion_statements >= 202411L && __SSE2__)\n #  define __glibcxx_simd 202506L\ndiff --git a/libstdc++-v3/include/std/contracts b/libstdc++-v3/include/std/contracts\nindex c1fe54750af..a0575fbefd9 100644\n--- a/libstdc++-v3/include/std/contracts\n+++ b/libstdc++-v3/include/std/contracts\n@@ -33,6 +33,7 @@\n #pragma GCC system_header\n \n #define __glibcxx_want_contracts\n+#define __glibcxx_want_replaceable_contract_violation_handler\n #include <bits/version.h>\n \n #ifdef __cpp_lib_contracts\n","prefixes":[]}