get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2226906/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2226906,
    "url": "http://patchwork.ozlabs.org/api/patches/2226906/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260422211752.3082604-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": "<20260422211752.3082604-1-jason@redhat.com>",
    "list_archive_url": null,
    "date": "2026-04-22T21:04:36",
    "name": "[16,RFA] c++: consteval, array, modules [PR124973]",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "d3e72cff05196b46cab1ae27a2aa88277b9aabab",
    "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/20260422211752.3082604-1-jason@redhat.com/mbox/",
    "series": [
        {
            "id": 501114,
            "url": "http://patchwork.ozlabs.org/api/series/501114/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=501114",
            "date": "2026-04-22T21:04:36",
            "name": "[16,RFA] c++: consteval, array, modules [PR124973]",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/501114/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2226906/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2226906/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=Vgo/U94x;\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=Vgo/U94x",
            "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 4g1CCx1FPnz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 07:34:21 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 2FADF4C7691F\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 21:34:19 +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 677AA4475562\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 21:17:56 +0000 (GMT)",
            "from mx-prod-mc-08.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-656-gt3__yYhMnuLMuYln6Yl8w-1; Wed,\n 22 Apr 2026 17:17:54 -0400",
            "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id DE58E18004A9\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 21:17:53 +0000 (UTC)",
            "from jason-thinkpadp1gen4i.rmtusma.csb (unknown [10.22.65.102])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 65E581800345; Wed, 22 Apr 2026 21:17:53 +0000 (UTC)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org 2FADF4C7691F",
            "OpenDKIM Filter v2.11.0 sourceware.org 677AA4475562"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 677AA4475562",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 677AA4475562",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776892676; cv=none;\n b=kfvCrsv6pYSasmOuoM+xYO4W4Ct92ouhHWxbkjsP8okVHMGO/qHWuDJNJtQglrU9Sm+BnFrqS0LWsXrw29QazvcqDWZbav8NLCjByLrTA8z9vSxnr0ErT7tHdnMNFANwxg6cdqXWzDd2HDNmrpZMKQt4VeFDaus9xxMpARf9E9k=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776892676; c=relaxed/simple;\n bh=ZfQjQpR6DEVwHXdmOy6GXRvvtYaI1/UiSsNqGeOfdxc=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=RIG1mDi9sMGjV1KonJJiGQvGaqYfu/blFKWOkgj3lrS95ga7BeaQNG45X5iQy3oy2cuVfJLdLgUrpvT3USJP77ekCRNzMqo8KAgWgsir/gKYkf5YUvgvfAqhPPdzIr4CQecLCxt8mb3URLWJDIIiYo68ueybgs+VoK5XX1pVouU=",
        "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=1776892676;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=dFHUn8EZlhvfsXay6QXFkp38vvucqD1t/R0Gcaa0UOI=;\n b=Vgo/U94xOI4xDc/2B/4evn1I8sLkrhbuNAoKdUhu1OMzjet0KbVFcM2wPGJNvlv8rJaFHw\n rTO7i7PRW3S2uGT5pd5VMOlVrQM6VtuJ1jfWggvhZcZJBEr6B8nxmprqDVvCg3n2bnsk1s\n 9Wrjp8grjbzUm2Pij09sx0ALk/eQj3w=",
        "X-MC-Unique": "gt3__yYhMnuLMuYln6Yl8w-1",
        "X-Mimecast-MFC-AGG-ID": "gt3__yYhMnuLMuYln6Yl8w_1776892674",
        "From": "Jason Merrill <jason@redhat.com>",
        "To": "gcc-patches@gcc.gnu.org",
        "Cc": "Jakub Jelinek <jakub@redhat.com>",
        "Subject": "[16 PATCH RFA] c++: consteval, array, modules [PR124973]",
        "Date": "Wed, 22 Apr 2026 17:04:36 -0400",
        "Message-ID": "<20260422211752.3082604-1-jason@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-MFC-PROC-ID": "7otYqAx0CUqFqT4Z9jNToa6BCSCKGM9E2ggPvWGJ3u0_1776892674",
        "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.  Also OK for 16 branch, since\nthis is an ice-on-valid regression from 15?\n\n-- 8< --\n\nHere the consteval holder constructor calls the defaulted element_array\nconstructor, which uses a VEC_INIT_EXPR to call the defaulted element\nconstructor.\n\nWhen we read in the holder constructor, we need to clone it, so we call\nfinish_function, which calls cp_fold_function_non_odr_use, which tries to\nconstant-evaluate the call to the element_array constructor.  This\neventually wants to evaluate the VEC_INIT_EXPR, which wants to call the\nelement constructor (complete object clone).  But we haven't cloned the\nelement constructor yet, so mark_used tries to synthesize it again, which\nbreaks because the constructor is already defined, just not cloned yet.\n\nWe should have cloned the element constructor first, but we didn't know that\nthe element_array constructor depends on it because VEC_INIT_EXPR doesn't\nexpress that; build_vec_init_expr calls build_vec_init_elt and then throws\nit away.  Perhaps we want to add the elt_init as an additional operand that\nis used to express dependencies, but ignored in expansion?\n\nIt would also be nice not to repeat all the finish_function passes when\nloading a function from a module; we already did\ncp_fold_function_non_odr_use and such for this function before writing out\nthe module, doing it again is a waste of time.\n\nBut also, trying to constant-evaluate the element_array constructor is wrong\nfor _non_odr_use, it shouldn't be doing any optimization folding.\n\nFurthermore, since the TARGET_EXPR is wrapped in an INIT_EXPR, we should\nnever have tried to fold it by itself, before cp_genericize_init_expr has a\nchance to elide it.  So let's only do that folding when ff_genericize, like\nthe other TARGET_EXPR transformations.  This is a much simpler fix for this\ntestcase.\n\nWhile we're at it, let's also suppress the other flag_no_inline-conditional\nfolding when ff_only_non_odr.\n\n\tPR c++/124973\n\tPR c++/120502\n\tPR c++/120005\n\ngcc/cp/ChangeLog:\n\n\t* cp-gimplify.cc (cp_fold_r) <case TARGET_EXPR>: Only\n\tdo optimization folding when ff_genericize.\n\t(cp_fold) <case CALL_EXPR>: Don't do\n\toptimization folding when ff_only_non_odr.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/modules/consteval-1_a.C: New test.\n\t* g++.dg/modules/consteval-1_b.C: New test.\n---\n gcc/cp/cp-gimplify.cc                        |  5 ++-\n gcc/testsuite/g++.dg/modules/consteval-1_a.C | 36 ++++++++++++++++++++\n gcc/testsuite/g++.dg/modules/consteval-1_b.C |  8 +++++\n 3 files changed, 48 insertions(+), 1 deletion(-)\n create mode 100644 gcc/testsuite/g++.dg/modules/consteval-1_a.C\n create mode 100644 gcc/testsuite/g++.dg/modules/consteval-1_b.C\n\n\nbase-commit: b8ac2356c691f76c19246c4c7b94c23015b8b8aa",
    "diff": "diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc\nindex 5bcf5168970..8ae66405817 100644\n--- a/gcc/cp/cp-gimplify.cc\n+++ b/gcc/cp/cp-gimplify.cc\n@@ -1717,7 +1717,8 @@ cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_)\n       break;\n \n     case TARGET_EXPR:\n-      if (!flag_no_inline)\n+      if (!flag_no_inline\n+\t  && (data->flags && ff_genericize))\n \tif (tree &init = TARGET_EXPR_INITIAL (stmt))\n \t  {\n \t    tree folded = maybe_constant_init (init, TARGET_EXPR_SLOT (stmt),\n@@ -3769,6 +3770,7 @@ cp_fold (tree x, fold_flags_t flags)\n \tif ((OPTION_SET_P (flag_fold_simple_inlines)\n \t     ? flag_fold_simple_inlines\n \t     : !flag_no_inline)\n+\t    && !(flags & ff_only_non_odr)\n \t    && call_expr_nargs (x) == 1\n \t    && decl_in_std_namespace_p (callee)\n \t    && DECL_NAME (callee) != NULL_TREE\n@@ -3881,6 +3883,7 @@ cp_fold (tree x, fold_flags_t flags)\n \t   Do constexpr expansion of expressions where the call itself is not\n \t   constant, but the call followed by an INDIRECT_REF is.  */\n \tif (callee && DECL_DECLARED_CONSTEXPR_P (callee)\n+\t    && !(flags & ff_only_non_odr)\n \t    && (!flag_no_inline\n \t\t|| lookup_attribute (\"always_inline\",\n \t\t\t\t     DECL_ATTRIBUTES (callee))))\ndiff --git a/gcc/testsuite/g++.dg/modules/consteval-1_a.C b/gcc/testsuite/g++.dg/modules/consteval-1_a.C\nnew file mode 100644\nindex 00000000000..dac678c32b1\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/modules/consteval-1_a.C\n@@ -0,0 +1,36 @@\n+// PR c++/124973\n+// { dg-do compile { target c++20 } }\n+// { dg-additional-options \"-fmodules\" }\n+\n+export module right;\t\t// { dg-module-cmi right }\n+\n+struct constexpr_move {\n+    constexpr_move() = default;\n+    constexpr_move(const constexpr_move&) = default;\n+    constexpr constexpr_move(constexpr_move&&) {}\n+};\n+\n+struct element {\n+    constexpr_move a;\n+    int b;\n+};\n+\n+template <unsigned N>\n+struct element_array {\n+    element data[ N ];\n+};\n+\n+template <unsigned N>\n+struct holder {\n+    consteval holder(element_array<N> values) :\n+        values_{static_cast<element_array<N>&&>(values)} {}\n+    element_array<N> values_;\n+};\n+\n+template <unsigned N>\n+constexpr auto holder_of = holder<N>{element_array<N>{}};\n+\n+export class environment {\n+    decltype(holder_of<1>) s1_{holder_of<1>};\n+    decltype(holder_of<2>) s2_{holder_of<2>};\n+};\ndiff --git a/gcc/testsuite/g++.dg/modules/consteval-1_b.C b/gcc/testsuite/g++.dg/modules/consteval-1_b.C\nnew file mode 100644\nindex 00000000000..14676e5dcea\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/modules/consteval-1_b.C\n@@ -0,0 +1,8 @@\n+// PR c++/124973\n+// { dg-do compile { target c++20 } }\n+// { dg-additional-options \"-fmodules\" }\n+\n+export module left;\t\t// { dg-module-cmi left }\n+import right;\n+\n+export auto xx(environment&) -> void;\n",
    "prefixes": [
        "16",
        "RFA"
    ]
}