Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2223581/?format=api
{ "id": 2223581, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2223581/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/ad_Cj95gktsie8-M@redhat.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.1/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 }, "msgid": "<ad_Cj95gktsie8-M@redhat.com>", "date": "2026-04-15T16:53:35", "name": "[v2] c++/reflection: generic lambda with dependent splice [PR123783]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "a017052f84ca2499d6ef0f0de768a0644ba95a56", "submitter": { "id": 14370, "url": "http://patchwork.ozlabs.org/api/1.1/people/14370/?format=api", "name": "Marek Polacek", "email": "polacek@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/ad_Cj95gktsie8-M@redhat.com/mbox/", "series": [ { "id": 500014, "url": "http://patchwork.ozlabs.org/api/1.1/series/500014/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500014", "date": "2026-04-15T16:53:35", "name": "[v2] c++/reflection: generic lambda with dependent splice [PR123783]", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/500014/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2223581/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2223581/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=d3BFAGoO;\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=d3BFAGoO", "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 4fwnL00dtKz1yHc\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 02:54:16 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 428D24BA23C0\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 16:54:14 +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 CCD384BA2E0A\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 16:53:45 +0000 (GMT)", "from mail-qv1-f71.google.com (mail-qv1-f71.google.com\n [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-656-IgsU1VHFPDarOU2pfPfZ9Q-1; Wed, 15 Apr 2026 12:53:40 -0400", "by mail-qv1-f71.google.com with SMTP id\n 6a1803df08f44-8954803bd74so74854576d6.0\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 09:53:39 -0700 (PDT)", "from redhat.com ([2603:7000:9500:10::1db4])\n by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8ae6cda4fa0sm15839936d6.36.2026.04.15.09.53.37\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 15 Apr 2026 09:53:37 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 428D24BA23C0", "OpenDKIM Filter v2.11.0 sourceware.org CCD384BA2E0A" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org CCD384BA2E0A", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org CCD384BA2E0A", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776272026; cv=none;\n b=NJKUWvZscZUgRS0Ca2KvhSKve6kaMbqcJhxUi6ZZRKWLKxNvtJXTjePUx/1atWsgF5jPyvl9ooVZCI1suJHzLZ+bOQ2EtfgmZdw0HJUeuc+01YdBiC6pufhkrTfBtsOElSbxS+hyR90XTrf3dA3RsIJWMc0cuJu51feoxXi+HP4=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776272026; c=relaxed/simple;\n bh=WulQYMSDPDpvrB/kljPzvU5ojvmIOnnov8hxJad+Pus=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=q1nTIhNy2DJ1ihSxfk4Z74ZgTxPeZSY/qBvqOl8mMsdcxOTfSr0ILf5LrR2twTZtcHk+todUP4caBDWCNlTElvz/gu23M8iqxlaqfz7EhwA3M6Y4uQKH4PALw2UwG8jrkwlEIQThleu5VAKCdO2eAXiPCKkn1P39Adwf7RGUELE=", "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=1776272025;\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 in-reply-to:in-reply-to:references:references;\n bh=zAdgaKz1/JxosYctfuTdql+fHdSQFTmJbTJJ/2Mrm3E=;\n b=d3BFAGoO4N+o80H7KHmzzbHBSSRYQmRSOWWtk1wsU4QmRfZvJrzQ019bLjrVUkrDSLCL7H\n //NYR/kJo/oI8qfNRCWRX1Ud4fA9UCrkNL5/ng2R1Vh1m2k7k4Xylr5q1AWVESYzNmJm4b\n 4pafFteLD2PHt/7sCSBvZTgHdE5svYI=", "X-MC-Unique": "IgsU1VHFPDarOU2pfPfZ9Q-1", "X-Mimecast-MFC-AGG-ID": "IgsU1VHFPDarOU2pfPfZ9Q_1776272019", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776272019; x=1776876819;\n h=user-agent:in-reply-to:content-disposition:mime-version:references\n :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=zAdgaKz1/JxosYctfuTdql+fHdSQFTmJbTJJ/2Mrm3E=;\n b=l1byKmlmHN9twvc7Hud2zoE8SYVh7Ya2sjI95UsOatiPgxUS36ia54OTZYtCYoHW1z\n Kgb0GMmRUzLQLyGylIIaFPGktlNUUf8w7TwjeGYonH8TP7NrMcS0g0Jd2WVFVij0nIob\n +wnKoVy/Fg6QbmKwxPIoxyJxRk+g27ncpu08jqgPhuqQb15a58MOMlhbzDW4E6umTxSD\n 1NLbEjiPvsKXzQXgofxaJJV7z36DMfvgBnzu71yxcdnHaaQJNAe/MTMpzb3tuCA40f2r\n pOUUrfFBk7p26pNNVV0uVtU0z++o6MgSWVBhS1I3jX7YTpLaC1B9F96YCl33Yb10RwMq\n n7rA==", "X-Gm-Message-State": "AOJu0Yz9m1559UVfw7piHb/zEzgGTbSD9b2CHW9zd22HIEjrXDIZJW41\n WZRQ2tHDcs48xOPXi+V3Uvvhc116l8OdsJIArB5wMasNrLxtNYtBYos/9rGbaOvCuFdwA2dloyD\n l3VHue3X8y1uitOJt7hYBNKTRLNDubrTDEgpDtxEz3Bt2el7NsiefOQ5KPXrhj4jEA7s=", "X-Gm-Gg": "AeBDieuRq+ygoAJHtaUYF1UBgC7V16QxqWS5vvEOsDF/h7eEUPadIJ95OZqHFOZrMoh\n JEgZDwudO2Hns2bhDA5K9kTH0fshLtVleWZxbG0qMvhA8OVKWS0Q1ANUljivCZIfRWN2iz7+ke2\n 66TsMUYXgjJNK1woTJGAU8T3Hi+CUzNk03rtuOgSxzlPdvCAthM2jdmNAKMi+QXjsV3O1wk1XRy\n 2edbTPQKYLu7HWl0B+KuKGzJ2gkNbQT5jLwV0Qs4tqVW0RB2KvyyEUPpdhvJVSlOMQIm0f9tfuu\n +pTTuuCQSO5hmsQhNFRQ8TBqIFDYYf5q1KGo/+ddBzKeywTTNjIwfHCfmljsoVkT5Yn28RJgS04\n L9w==", "X-Received": [ "by 2002:a05:6214:311c:b0:8a0:f0d5:6c9c with SMTP id\n 6a1803df08f44-8ac862891f9mr350406336d6.55.1776272018709;\n Wed, 15 Apr 2026 09:53:38 -0700 (PDT)", "by 2002:a05:6214:311c:b0:8a0:f0d5:6c9c with SMTP id\n 6a1803df08f44-8ac862891f9mr350405706d6.55.1776272018054;\n Wed, 15 Apr 2026 09:53:38 -0700 (PDT)" ], "Date": "Wed, 15 Apr 2026 12:53:35 -0400", "From": "Marek Polacek <polacek@redhat.com>", "To": "Jason Merrill <jason@redhat.com>", "Cc": "GCC Patches <gcc-patches@gcc.gnu.org>", "Subject": "[PATCH v2] c++/reflection: generic lambda with dependent splice\n [PR123783]", "Message-ID": "<ad_Cj95gktsie8-M@redhat.com>", "References": "<20260415161149.691849-1-polacek@redhat.com>\n <74a60da4-10cb-4cd8-8a01-2e564b54b8e3@redhat.com>", "MIME-Version": "1.0", "In-Reply-To": "<74a60da4-10cb-4cd8-8a01-2e564b54b8e3@redhat.com>", "User-Agent": "Mutt/2.3.1 (2026-03-20)", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "qEul01yYT9LsXEXybm6NYHNHQyY3Bh5pBXVCb7HU8_k_1776272019", "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>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "On Wed, Apr 15, 2026 at 12:26:14PM -0400, Jason Merrill wrote:\n> On 4/15/26 12:11 PM, Marek Polacek wrote:\n> > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?\n> \n> OK.\n> \n> It might be nice to somehow refer to the rule that makes this explicitly\n> ill-formed:\n> \n> https://eel.is/c++draft/expr#prim.splice-2.1.4.1\n\nSure, done here. I'm about to push this.\n\n-- >8 --\nFor a generic lambda, we normally collect the captures while parsing\nthe lambda: finish_id_expression calls process_outer_var_ref which does\nadd_capture. Then when instantiating, we'll find the capture via\nretrieve_local_specialization. Once the closure type has been\nfinalized, it's frozen and we can't add new fields. This is what\nhappens in the following test though, which is the reason we crash:\n\n [&]<auto> {\n [:e:];\n }\n\nwhere while parsing we can't know what the splice will designate.\nWe'll only find out after we've substituted the splice but then it's\ntoo late to capture anything.\n\nA possible solution would be to speculatively capture all locals when\nwe see a dependent splice in a generic lambda. But since this test is\ninvalid anyway, that would be a lot of work for no good reason. So this\npatch changes the internal_error to an ordinary error.\n\n\tPR c++/123783\n\ngcc/cp/ChangeLog:\n\n\t* lambda.cc (add_capture): When trying to capture something in\n\tan instantiation of generic lambda, give an error instead of an ICE.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/reflect/dep14.C: New test.\n\nReviewed-by: Jason Merrill <jason@redhat.com>\nReviewed-by: Patrick Palka <ppalka@redhat.com>\n---\n gcc/cp/lambda.cc | 15 +++++++-\n gcc/testsuite/g++.dg/reflect/dep14.C | 57 ++++++++++++++++++++++++++++\n 2 files changed, 70 insertions(+), 2 deletions(-)\n create mode 100644 gcc/testsuite/g++.dg/reflect/dep14.C\n\n\nbase-commit: 0c286ea4006d31d066e7b11714e04f4be0a912de", "diff": "diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc\nindex e1ff304ffe8..af0b66afe81 100644\n--- a/gcc/cp/lambda.cc\n+++ b/gcc/cp/lambda.cc\n@@ -729,8 +729,19 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,\n && current_class_type == LAMBDA_EXPR_CLOSURE (lambda))\n {\n if (COMPLETE_TYPE_P (current_class_type))\n-\tinternal_error (\"trying to capture %qD in instantiation of \"\n-\t\t\t\"generic lambda\", id);\n+\t{\n+\t /* This can happen for code like [&]<auto e> { [:e:]; } where\n+\t we can't figure out what the splice will designate while parsing;\n+\t we'll only know it after we've substituted the splice, but then\n+\t it's too late to capture anything. This code is ill-formed as\n+\t per [expr.prim.splice]/2.1.4.1: The expression is ill-formed if\n+\t S is ... a local entity such that ... there is a lambda scope that\n+\t intervenes between the expression and the point at which S was\n+\t introduced and the expression would be potentially evaluated. */\n+\t error (\"trying to capture %qD in instantiation of generic lambda\",\n+\t\t id);\n+\t return error_mark_node;\n+\t}\n finish_member_declaration (member);\n }\n \ndiff --git a/gcc/testsuite/g++.dg/reflect/dep14.C b/gcc/testsuite/g++.dg/reflect/dep14.C\nnew file mode 100644\nindex 00000000000..2be447ee972\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/dep14.C\n@@ -0,0 +1,57 @@\n+// PR c++/123783\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+#include <meta>\n+\n+namespace __impl {\n+ template<auto... vals>\n+ struct replicator_type {\n+ template<typename F>\n+ constexpr void operator>>(F body) const {\n+ (body.template operator()<vals>(), ...);\n+ }\n+ };\n+\n+ template<auto... vals>\n+ replicator_type<vals...> replicator = {};\n+}\n+\n+template<typename R>\n+consteval auto expand(R range) {\n+ std::vector<std::meta::info> args;\n+ for (auto r : range) {\n+ args.push_back(reflect_constant(r));\n+ }\n+ return substitute(^^__impl::replicator, args);\n+}\n+\n+int func(int counter, float factor) {\n+ std::array<void *, parameters_of(^^func).size()> args;\n+\n+ std::size_t i = 0;\n+ [:expand(parameters_of(^^func)):] >> [&i, &counter, &factor, &args]<auto e>\n+ {\n+ args[i++] = &[:e:]; // { dg-error \"use of local variable\" }\n+ };\n+ return 0;\n+}\n+\n+int func2(int counter, float factor) {\n+ std::array<void *, parameters_of(^^func).size()> args;\n+\n+ std::size_t i = 0;\n+ [:expand(parameters_of(^^func)):] >> [&]<auto e>\n+ {\n+ args[i++] = &[:e:]; // { dg-error \"use of local variable|trying to capture \\[^\\n\\r]* in instantiation of generic lambda\" }\n+ };\n+ return 0;\n+}\n+\n+int main()\n+{\n+ func(11, 22);\n+ func(33, 44);\n+ func2(11, 22);\n+ func2(33, 44);\n+}\n", "prefixes": [ "v2" ] }