Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2224178/?format=api
{ "id": 2224178, "url": "http://patchwork.ozlabs.org/api/patches/2224178/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260417024048.3738013-1-jason@redhat.com/", "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": "<20260417024048.3738013-1-jason@redhat.com>", "list_archive_url": null, "date": "2026-04-17T02:40:33", "name": "[pushed] c++: constexpr call hashing and gc [PR124632]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "761b69cead6291a5f1752ca7ff8787950617d5fd", "submitter": { "id": 4337, "url": "http://patchwork.ozlabs.org/api/people/4337/?format=api", "name": "Jason Merrill", "email": "jason@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260417024048.3738013-1-jason@redhat.com/mbox/", "series": [ { "id": 500225, "url": "http://patchwork.ozlabs.org/api/series/500225/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500225", "date": "2026-04-17T02:40:33", "name": "[pushed] c++: constexpr call hashing and gc [PR124632]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500225/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2224178/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2224178/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=FY2j2M3E;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::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=FY2j2M3E", "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\n [IPv6:2620:52:6:3111::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 4fxfKM1nT3z1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 12:41:42 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id E57CC4BAD147\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 02:41:39 +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 D52814BA23E6\n for <gcc-patches@gcc.gnu.org>; Fri, 17 Apr 2026 02:41:01 +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-564-MkeBUYHaPFaYccxPj5m5lw-1; Thu,\n 16 Apr 2026 22:40:51 -0400", "from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\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 6BC9A18003F6\n for <gcc-patches@gcc.gnu.org>; Fri, 17 Apr 2026 02:40:50 +0000 (UTC)", "from jason-thinkpadp1gen4i.rmtusma.csb (unknown [10.22.66.21])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 0E7DB180035F\n for <gcc-patches@gcc.gnu.org>; Fri, 17 Apr 2026 02:40:49 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org E57CC4BAD147", "OpenDKIM Filter v2.11.0 sourceware.org D52814BA23E6" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org D52814BA23E6", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org D52814BA23E6", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776393662; cv=none;\n b=mchUBAz9ehk5JSDzLMW2K5gou+DdNuwRD6RzJoOM9YzmV4oHJD/xUOf7DFv0oQYc+PWV45VArhskcJd8MVviY2Fq6Kuhm8SO01E1si0XDDz443mZOI0ZEbkEXDGiY9nJAghXu2tzBT8Tk0fOLKPD8I700Q5V2PmIJq5Tyrw5CWc=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776393662; c=relaxed/simple;\n bh=4IyhD6jcAWcQ0XemDEGbtIWec056Ut0sObgtFfxnyuQ=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=JvcNPyLNy9NBwxH3oi2w+5n5J9H6KR8saP7Wv+aCB7jXVyys8jEai5CUATCAZzI9zeatqNc5Q1dMGWw2rW/v3/DDJmxHOsiHJpXT29g4Yw9IkZQi4b6UaCQUrE1UK8y5rRlNHj5oA7YePHXG+92Zr8c+PZ4IqFE43x7LjyHMXwg=", "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=1776393661;\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=BdN5O2DKgqfk7BSALSubxV9p94WEWy2dQe030VIamww=;\n b=FY2j2M3Erf5vN9bLYPho049kjzr2lwFQzLM2aBhwScEZE6ti0+UUQggJucPCVT4OBkMn40\n oqP1sBhsSl6qrGdbhvZM5KgvMzQnw/k3p+uqvWvr8hI83g6qc6KoV/0FCske8045+2XOsL\n EuQMtvIbWjVY4akYNoNt4wo1Z5HwUTU=", "X-MC-Unique": "MkeBUYHaPFaYccxPj5m5lw-1", "X-Mimecast-MFC-AGG-ID": "MkeBUYHaPFaYccxPj5m5lw_1776393650", "From": "Jason Merrill <jason@redhat.com>", "To": "gcc-patches@gcc.gnu.org", "Subject": "[pushed] c++: constexpr call hashing and gc [PR124632]", "Date": "Thu, 16 Apr 2026 22:40:33 -0400", "Message-ID": "<20260417024048.3738013-1-jason@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.111", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "Nh9f4572C_9jQ1kyYVXG7nbATbA0wQ06Cj_vah1ths8_1776393650", "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": "Tested x86_64-pc-linux-gnu, applying to trunk.\n\n-- 8< --\n\nIn cxx_eval_call_expression, we unshare an argument that goes into\nconstexpr_call::bindings so it's independent, and then if it's a CONSTRUCTOR\nwe unshare it again before putting it in the constexpr value hashtable so\nany modifications within the function don't affect the bindings. And then\nwe free these latter CONSTRUCTOR if they aren't part of the return value.\n\nIn explicit-obj-lambda2.C, cl5 is a recursive constexpr lambda that takes a\nclass (the closure) by value. If -Wtautological-compare is enabled, we try\nto constant-fold cl5(5) to see if has a constant value. In evaluating the\nouter call we have an empty CONSTRUCTOR argument {} that we unshare twice.\n\nWhen we try to evaluate the recursive call, the second unshare from the\nfirst call initially goes into bindings. But since this is a recursive call\nget_fundef_copy needs need to make a copy of the FUNCTION_DECL, and since\nthis evaluation is for a warning uid_sensitive_constexpr_evaluation_p is\ntrue, so we can't make a copy, so evaluating the recursive copy fails\nwithout ever unsharing the argument.\n\nThen when we get back to finishing up the outer call we ggc_free the\nunshared CONSTRUCTOR that we don't need anymore. But the recursive call\nalready added it to the constexpr_call_table, so now the entry there is\nreferring to freed memory.\n\nThe solution is doing the first unshare immediately when we create the entry\nin the constexpr_call_table, not later after get_fundef_copy. This should\nalso mean less unsharing, as we now only do the first unshare when creating\nthe constexpr_call_table entry, not on subsequent evaluations. This only\naffects uncacheable calls, but that's a significant subset.\n\n\tPR c++/124632\n\ngcc/cp/ChangeLog:\n\n\t* constexpr.cc (cxx_eval_call_expression): Unshare bindings\n\tsooner.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/cpp23/explicit-obj-lambda2.C: Do strict GC and -Wall.\n---\n gcc/cp/constexpr.cc | 18 +++++++++++-------\n .../g++.dg/cpp23/explicit-obj-lambda2.C | 3 +++\n 2 files changed, 14 insertions(+), 7 deletions(-)\n\n\nbase-commit: 20230911fcadf09d2b79a75465c16d9d3397a591", "diff": "diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc\nindex fb9ae760e92..5b7d385fa97 100644\n--- a/gcc/cp/constexpr.cc\n+++ b/gcc/cp/constexpr.cc\n@@ -4395,6 +4395,16 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,\n \t *entry = new_call;\n \t entry->result (ctx->manifestly_const_eval) = unknown_type_node;\n \t fb.preserve ();\n+\n+\t /* Unshare args going into the hash table to separate them\n+\t\t from the caller's context, for better GC and to avoid\n+\t\t problems with verify_gimple. */\n+\t tree bound = new_call.bindings;\n+\t for (int i = 0; i < TREE_VEC_LENGTH (bound); ++i)\n+\t\t{\n+\t\t tree &arg = TREE_VEC_ELT (bound, i);\n+\t\t arg = unshare_expr_without_location (arg);\n+\t\t}\n \t }\n \t}\n /* Calls that are in progress have their result set to unknown_type_node,\n@@ -4453,13 +4463,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,\n \t tree arg = TREE_VEC_ELT (bound, i);\n \t if (entry)\n \t\t{\n-\t\t /* Unshare args going into the hash table to separate them\n-\t\t from the caller's context, for better GC and to avoid\n-\t\t problems with verify_gimple. */\n-\t\t arg = unshare_expr_without_location (arg);\n-\t\t TREE_VEC_ELT (bound, i) = arg;\n-\n-\t\t /* And then unshare again so the callee doesn't change the\n+\t\t /* Unshare again so the callee doesn't change the\n \t\t argument values in the hash table. XXX Could we unshare\n \t\t lazily in cxx_eval_store_expression? */\n \t\t arg = unshare_constructor (arg);\ndiff --git a/gcc/testsuite/g++.dg/cpp23/explicit-obj-lambda2.C b/gcc/testsuite/g++.dg/cpp23/explicit-obj-lambda2.C\nindex 827197a6667..4979ad57a14 100644\n--- a/gcc/testsuite/g++.dg/cpp23/explicit-obj-lambda2.C\n+++ b/gcc/testsuite/g++.dg/cpp23/explicit-obj-lambda2.C\n@@ -1,6 +1,9 @@\n // P0847R7\n // { dg-do run { target c++23 } }\n \n+// PR c++/124632\n+// { dg-additional-options \"-Wall --param ggc-min-expand=0 --param ggc-min-heapsize=0\" }\n+\n // recursive lambdas\n \n inline constexpr int correct_result = 5 + 4 + 3 + 2 + 1; \n", "prefixes": [ "pushed" ] }