Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2222986/?format=api
{ "id": 2222986, "url": "http://patchwork.ozlabs.org/api/patches/2222986/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/ad3oBsKzdenydbTa@tucnak/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "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, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<ad3oBsKzdenydbTa@tucnak>", "list_archive_url": null, "date": "2026-04-14T07:08:54", "name": "c++: Fix up constexpr EH handling of TARGET_EXPR temporaries [PR124755]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "08b59facd65a8706615f03b5f0cf12192abbf9a4", "submitter": { "id": 671, "url": "http://patchwork.ozlabs.org/api/people/671/?format=api", "name": "Jakub Jelinek", "email": "jakub@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/ad3oBsKzdenydbTa@tucnak/mbox/", "series": [ { "id": 499790, "url": "http://patchwork.ozlabs.org/api/series/499790/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=499790", "date": "2026-04-14T07:08:54", "name": "c++: Fix up constexpr EH handling of TARGET_EXPR temporaries [PR124755]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499790/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2222986/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2222986/checks/", "tags": {}, "related": [], "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=ciigC89W;\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=ciigC89W", "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.129.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 4fvwQ82xWhz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 17:09:50 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id CCAAC4BA2E13\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 07:09:48 +0000 (GMT)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id ECFC94BA2E0D\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 07:09:10 +0000 (GMT)", "from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-277-vE8Sy5fmO--PwRPI2Qbw6w-1; Tue,\n 14 Apr 2026 03:08:59 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id B27CD1800250\n for <gcc-patches@gcc.gnu.org>; Tue, 14 Apr 2026 07:08:58 +0000 (UTC)", "from tucnak.zalov.cz (unknown [10.44.33.129])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 08C4219560AB; Tue, 14 Apr 2026 07:08:57 +0000 (UTC)", "from tucnak.zalov.cz (localhost [127.0.0.1])\n by tucnak.zalov.cz (8.18.1/8.18.1) with ESMTPS id 63E78t4V2951717\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Tue, 14 Apr 2026 09:08:55 +0200", "(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63E78s1A2951716;\n Tue, 14 Apr 2026 09:08:54 +0200" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org CCAAC4BA2E13", "OpenDKIM Filter v2.11.0 sourceware.org ECFC94BA2E0D" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org ECFC94BA2E0D", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org ECFC94BA2E0D", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776150551; cv=none;\n b=F7x/UK1S4871LVCOofA/he42NYLi36fXjFfzuEtnet9TmAY1nzWbi1ySAXpvgkcuygwlkPkCOhyf9ixdQvJBMB4MP0CQxQnW+xHchiFbVkfiL5L9QIH+HanF1nMzgXjIO4CW3IH99Y8+DPy03E3grWZ81RLrt15PCC6X3xG93WI=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776150551; c=relaxed/simple;\n bh=UgfCJKRQ/arxPfMPYqnnSpRBlYE/2bCyD9cuK0GXrHI=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=fCEXqvZskPxtEOE1lv/7OzseSO/LxLcCiWK1Jb4jjWA3tzgTbJ+PS7wDVTVx+fQhcO6x+a+UBrPlFrPC8Dttv9mZAWzeGlbiCNVnRZPDWSjVQ7L0ydDHwSevw34KA26ZKDbXvCwKAdRuqp+U35Qe74Ma6PzVZeMRyswEY8nD5E8=", "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=1776150550;\n h=from:from:reply-to:reply-to:subject:subject:date:date:\n message-id:message-id:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=19VHWvI/pWxr77L+/8vH8EHsDhIZURYswQ8/j4MU4+Y=;\n b=ciigC89WLzaxh1X55uVRMQk+z6+sOlfBYvmoJ+dyoJOK/pWWfC1o92I+Y3JDANQbDzLlNk\n B78xufhxQinPcAY4U8m4Hrx27E0H91HW6OsgOp2YQ188DVVSJF6Tb0hWRktoAyle48H8P2\n WFSCsgwh1Ljm0wLGuYI5WU4zYP70nhE=", "X-MC-Unique": "vE8Sy5fmO--PwRPI2Qbw6w-1", "X-Mimecast-MFC-AGG-ID": "vE8Sy5fmO--PwRPI2Qbw6w_1776150538", "Date": "Tue, 14 Apr 2026 09:08:54 +0200", "From": "Jakub Jelinek <jakub@redhat.com>", "To": "Jason Merrill <jason@redhat.com>", "Cc": "gcc-patches@gcc.gnu.org", "Subject": "[PATCH] c++: Fix up constexpr EH handling of TARGET_EXPR temporaries\n [PR124755]", "Message-ID": "<ad3oBsKzdenydbTa@tucnak>", "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": "qLhNBwqdAlDBvK3R14h1oJGYAelMddqRAMhRhlEyMkw_1776150538", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "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>", "Reply-To": "Jakub Jelinek <jakub@redhat.com>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "Hi!\n\nThe following testcase is incorrectly rejected with spurious error about\n<anonymous> used outside of its lifetime.\nWe constant evaluate\n <<cleanup_point <<< Unknown tree: expr_stmt\n (void) (n = TARGET_EXPR <D.2693, foo (m)>, n + D.2693) >>>>>;\nin a loop, D.2693 is integral TARGET_EXPR_SLOT and foo throws in the second\nor later iteration. Because D.2693 is not is_complex nor has\naggregate/vector type, we don't ctx->global->put_value (slot, something)\nuntil the TARGET_EXPR_INITIAL evaluation successfully finishes, at which\npoint we ctx->save_exprs->safe_push (slot); and\nctx->global->put_value (slot, r); Because of the save_exprs push, the\nCLEANUP_POINT_EXPR handling then\n /* Forget SAVE_EXPRs and TARGET_EXPRs created by this\n full-expression. */\n for (tree save_expr : save_exprs)\n destroy_value_checked (ctx, save_expr, non_constant_p);\nand that ctx->global->put_value (slot, void_node); (i.e. marks it out of\nlifetime). In the second iteration, we again don't call put_value on the\nslot early, notice TARGET_EXPR_INITIAL evaluation throws, still\nctx->save_exprs->safe_push (slot); but then return. That means\nthe remembered value is still void_node and so destroy_value_checked\ncomplains.\n\nThe following patch fixes that by calling put_value in the case where\nwe know we haven't changed it yet (i.e. it is not is_complex and it doesn't\nhave aggregate/vector type), so that destroy_value_checked doesn't complain.\n\nBoptstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?\n\n2026-04-14 Jakub Jelinek <jakub@redhat.com>\n\n\tPR c++/124755\n\t* constexpr.cc (cxx_eval_constant_expression): If TARGET_EXPR_INITIAL\n\tthrows and !is_complex and type is neither aggregate nor vector,\n\tcall ctx->global->put_value (slot, NULL) before returning.\n\n\t* g++.dg/cpp26/constexpr-eh19.C: New test.\n\n\n\tJakub", "diff": "--- gcc/cp/constexpr.cc.jj\t2026-04-03 20:46:22.849229712 +0200\n+++ gcc/cp/constexpr.cc\t2026-04-13 16:17:30.760424372 +0200\n@@ -9504,7 +9504,16 @@ cxx_eval_constant_expression (const cons\n \tif (ctx->save_exprs)\n \t ctx->save_exprs->safe_push (slot);\n \tif (*jump_target)\n-\t return NULL_TREE;\n+\t {\n+\t if (!is_complex\n+\t\t&& !(AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type)))\n+\t /* If TARGET_EXPR_INITIAL throws exception and slot's value\n+\t\t has not been changed yet, CLEANUP_POINT_EXPR handling\n+\t\t could see there void_node from a previous evaluation\n+\t\t and complain. */\n+\t ctx->global->put_value (slot, NULL_TREE);\n+\t return NULL_TREE;\n+\t }\n \tif (!is_complex)\n \t {\n \t r = unshare_constructor (r);\n--- gcc/testsuite/g++.dg/cpp26/constexpr-eh19.C.jj\t2026-04-13 16:22:53.086944490 +0200\n+++ gcc/testsuite/g++.dg/cpp26/constexpr-eh19.C\t2026-04-13 16:23:15.592561870 +0200\n@@ -0,0 +1,33 @@\n+// PR c++/124755\n+// { dg-do compile { target c++26 } }\n+\n+constexpr int\n+foo (int a)\n+{\n+ return a ? throw 1 : 0;\n+}\n+\n+consteval int\n+bar ()\n+{\n+ int n = 0;\n+ int a[] = { 0, 1 };\n+ for (int m : a)\n+ n += foo (m);\n+ return n;\n+}\n+\n+consteval int\n+baz ()\n+{\n+ try\n+ {\n+ return bar ();\n+ }\n+ catch (...)\n+ {\n+ return -1;\n+ }\n+}\n+\n+static_assert (baz () == -1);\n", "prefixes": [] }