Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2195312/?format=api
{ "id": 2195312, "url": "http://patchwork.ozlabs.org/api/patches/2195312/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/KIeTB2eyZrInlFm_dD95Vj61oRc2OuOeJL4lRR3u-KaQSVuFb3qVMZCGbESTWZT8hzgds6PQgS-4oZlcrob0goQ60IKER3eFiu-Oq85qkZg=@protonmail.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": "<KIeTB2eyZrInlFm_dD95Vj61oRc2OuOeJL4lRR3u-KaQSVuFb3qVMZCGbESTWZT8hzgds6PQgS-4oZlcrob0goQ60IKER3eFiu-Oq85qkZg=@protonmail.com>", "list_archive_url": null, "date": "2026-02-10T18:14:02", "name": "[v3] c++/reflection: Allow address-splicing of non-static members [PR123660, PR123661]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "98407dad5270932ba4534408bf88cb89dc60962f", "submitter": { "id": 92603, "url": "http://patchwork.ozlabs.org/api/people/92603/?format=api", "name": "Boris Staletic", "email": "boris.staletic@protonmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/KIeTB2eyZrInlFm_dD95Vj61oRc2OuOeJL4lRR3u-KaQSVuFb3qVMZCGbESTWZT8hzgds6PQgS-4oZlcrob0goQ60IKER3eFiu-Oq85qkZg=@protonmail.com/mbox/", "series": [ { "id": 491722, "url": "http://patchwork.ozlabs.org/api/series/491722/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=491722", "date": "2026-02-10T18:14:02", "name": "[v3] c++/reflection: Allow address-splicing of non-static members [PR123660, PR123661]", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/491722/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2195312/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2195312/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 (2048-bit key;\n secure) header.d=protonmail.com header.i=@protonmail.com header.a=rsa-sha256\n header.s=protonmail3 header.b=gjnvXXQk;\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 (2048-bit key,\n secure) header.d=protonmail.com header.i=@protonmail.com header.a=rsa-sha256\n header.s=protonmail3 header.b=gjnvXXQk", "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=protonmail.com", "sourceware.org; spf=pass smtp.mailfrom=protonmail.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=109.224.244.27" ], "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 4f9V8l1Mk8z1xvb\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 11 Feb 2026 05:15:03 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 320644BA23C2\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 10 Feb 2026 18:15:01 +0000 (GMT)", "from mail-24427.protonmail.ch (mail-24427.protonmail.ch\n [109.224.244.27])\n by sourceware.org (Postfix) with ESMTPS id BB1D34BA23C0\n for <gcc-patches@gcc.gnu.org>; Tue, 10 Feb 2026 18:14:08 +0000 (GMT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 320644BA23C2", "OpenDKIM Filter v2.11.0 sourceware.org BB1D34BA23C0" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org BB1D34BA23C0", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org BB1D34BA23C0", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770747248; cv=none;\n b=ohNz34WBhU0LZ1yBhlshNIeuBbZPiNDQACGRaiui6GGGG1QGGvPbsmSLrw2qZsfuf04gzPXD1wzNgTmuSCfDE/Lu/nOuqXEYMda58Eto3uWFxh2y4eEbCe8aRewzgtFQjNax/+HvhEs8DGCFKXb1SfNuGvJnd7w1ckHqBIdB7bs=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1770747248; c=relaxed/simple;\n bh=wNX2gtc++uP+f00Aq7tXg9QE7NUnKM5qNAkwwsHLb4A=;\n h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version;\n b=N1eOlvdENLad51JFccHOnjlG61BCc2JVI7IvT9FFYi+Mzz0mvuRwvQj7XYlbh3ORpTy8XDTRZB4rpIpOrJj5N36OObVNo5Er7sSKMvoyARIs3d4Jk0df9TbiwmH5nJdvmOyUZSFzzYW/b+kcnlCxrkHRwpXrc/vp2E/E1HVOOD0=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n s=protonmail3; t=1770747247; x=1771006447;\n bh=831TO8koJ/YwMcGkY8Rabs5fATh+vKFyJA5W+hwiots=;\n h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n Message-ID:BIMI-Selector;\n b=gjnvXXQkDbnwtjEeLj/hCWQGgkbkuw25i+abJO3hoVvmpw+spXhGbvrcl/kbGGKn2\n OFDDyoTLIfcv29OLm9NGRuxtDZUgm8g5gBx566rgKBlYq2XTZzK3/QGM7eP0N3v6i9\n ewQtNHxwX87nlxCsIGc9htLi9pLJ+Vd/zQpDDHtXew4S2TJ+jn2viD9LQ075Ksspdj\n Hj4VOyaHStoot9Wd0MJ5q8EWTNDzJuGWl1NNuaEaSQ5ZmiowxMsKn/Gp+6EebYElvb\n IlmTjGD1/d5CEkdwsO/xyN7u408j6ZM8PahJ5J8wRcWBHuSYb6NaNCq4FNjrBHlsS2\n Zv5V6poYyHtVQ==", "Date": "Tue, 10 Feb 2026 18:14:02 +0000", "To": "Marek Polacek <polacek@redhat.com>", "From": "Boris Staletic <boris.staletic@protonmail.com>", "Cc": "Jason Merrill <jason@redhat.com>,\n \"gcc-patches@gcc.gnu.org\" <gcc-patches@gcc.gnu.org>", "Subject": "[PATCH v3] c++/reflection: Allow address-splicing of non-static\n members [PR123660, PR123661]", "Message-ID": "\n <KIeTB2eyZrInlFm_dD95Vj61oRc2OuOeJL4lRR3u-KaQSVuFb3qVMZCGbESTWZT8hzgds6PQgS-4oZlcrob0goQ60IKER3eFiu-Oq85qkZg=@protonmail.com>", "In-Reply-To": "<aYttHwV5whZPVQzA@redhat.com>", "References": "\n <_DD4SpzylKPGl3gGw_SrcsTF2vyhCkzLwAwNOpxnNFFbompQs2gg_gLt1RI0sF6DckMLdiCh29Y1Nmryb_xrjRzVQYQM8BPNfaHS3FBp2fg=@protonmail.com>\n <2619c114-ab42-4056-b781-a88c1dbe238e@redhat.com>\n <aYocQULe6N7MLPLy@redhat.com>\n <RJ_IMfkV_h9rh8RJhobN4Sm1Iv2qG-1mtU2hLPnDqPzV6Hkir8j4bOWlSolYRIoF-MQ6GaA-TWL_AfbMmRHm2Ls43ZuOfHL5wTXwbG4_wFk=@protonmail.com>\n <6bab907e-1155-4f01-a351-dd2407476b09@redhat.com>\n <GEOlz8HqYHLUMdEktDEzOoO7CPCILCsQ6Ptbkszwu86OjETT9Jft2lVNzjtJTmRbrfORsgtvfmoia4tZ1FDFMZ9e7wBJY3D3zKy-My3W3qQ=@protonmail.com>\n <aYthadsYFPWXCdRM@redhat.com>\n <dzRY0GQFm0qlZEOkjCnq2_vRUwxqQF-0oBDm037Thd7iYnwwAKfGZOVSONJjD3JmF46aiz3Zal_-LHoCvekESA4j_-uu88Y6HztU8WfylcI=@protonmail.com>\n <aYttHwV5whZPVQzA@redhat.com>", "Feedback-ID": "35547776:user:proton", "X-Pm-Message-ID": "e171fc314e66674e038907d53deacc3e5a8f71de", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "quoted-printable", "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 Tuesday, February 10th, 2026 at 5:38 PM, Marek Polacek <polacek@redhat.com> wrote:\n\n> On Tue, Feb 10, 2026 at 05:32:22PM +0000, Boris Staletic wrote:\n> > On Tuesday, February 10th, 2026 at 4:49 PM, Marek Polacek <polacek@redhat.com> wrote:\n> >\n> > > On Tue, Feb 10, 2026 at 03:26:37PM +0000, Boris Staletic wrote:\n> > > > On Tuesday, February 10th, 2026 at 2:05 PM, Jason Merrill <jason@redhat.com> wrote:\n> > > >\n> > > > >\n> > > > >\n> > > >\n> > > > Snipped older discussions for brevity.\n> > > >\n> > > > > >\n> > > > > > Here's a v2 of the patch, bootstrapped and tested on x86_64-pc-linux-gnu.\n> > > > > > -- >8 --\n> > > > > > In case of expressions like `&[:expr:]` where `expr` depends on a\n> > > > > > template parameter, and the splice expression represents a `FIELD_DECL` or\n> > > > > > a non-static member `FUNCTION_DECL`, that's exactly what we'd pass on.\n> > > > > > However, `build_x_unary_op()` for these expressions is expecting an\n> > > > > > `OFFSET_REF`. `OFFSET_REF` is also what gets passed to\n> > > > > > `build_x_unary_op()` when templates are not involved.\n> > > > > >\n> > > > > > There's also a difference between the template argument being a type and\n> > > > > > using `members_of()` to get to the reflections of members (in which case\n> > > > > > evaluating the `SPLICE_EXPR` returns a `FUNCTION_DECL` - `splice10.C`\n> > > > > > test) and passing `^^T::member` as the template argument (in which case\n> > > > > > evaluating the `SPLICE_EXPR` returns a `BASELINK` - `splice11.C`).\n> > > > > >\n> > > > > > Signed-off-by: Boris Staletic boris.staletic@protonmail.com\n> > > > > >\n> > > > > > PR c++/123660\n> > > > > > PR c++/123661\n> > > > > >\n> > > > > > gcc/cp/ChangeLog:\n> > > > > >\n> > > > > > * pt.cc (tsubst_splice_expr): Handle pointers to non-static members\n> > > > > > from splice expressions\n> > > > > >\n> > > > > > gcc/testsuite/ChangeLog:\n> > > > > >\n> > > > > > * g++.dg/reflect/splice10.C: New test.\n> > > > > > * g++.dg/reflect/splice11.C: New test.\n> > > > > > ---\n> > > > > > gcc/cp/pt.cc | 14 ++++++++++++\n> > > > > > gcc/testsuite/g++.dg/reflect/splice10.C | 28 ++++++++++++++++++++++++\n> > > > > > gcc/testsuite/g++.dg/reflect/splice11.C | 29 +++++++++++++++++++++++++\n> > > > > > 3 files changed, 71 insertions(+)\n> > > > > > create mode 100644 gcc/testsuite/g++.dg/reflect/splice10.C\n> > > > > > create mode 100644 gcc/testsuite/g++.dg/reflect/splice11.C\n> > > > > >\n> > > > > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc\n> > > > > > index 049bbf07e0..0c0076c9a4 100644\n> > > > > > --- a/gcc/cp/pt.cc\n> > > > > > +++ b/gcc/cp/pt.cc\n> > > > > > @@ -16755,6 +16755,20 @@ tsubst_splice_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)\n> > > > > > op = splice (op);\n> > > > > > if (op == error_mark_node)\n> > > > > > return error_mark_node;\n> > > > > > +\n> > > > > > + if (SPLICE_EXPR_ADDRESS_P (t) && !TREE_STATIC (TREE_TYPE (op)))\n> > > > >\n> > > > >\n> > > > > TREE_STATIC on a type isn't meaningful, the checks below are enough.\n> > > >\n> > > > I thought that was fishy... You're right, everything works without that check.\n> > > >\n> > > > >\n> > > > > > + {\n> > > > > > + if (TREE_CODE (op) == BASELINK\n> > > > > > + && TREE_CODE (TREE_TYPE (op)) == METHOD_TYPE)\n> > > > >\n> > > > >\n> > > > > It shouldn't be necessary to check for METHOD_TYPE; any class member is\n> > > > > suitable for passing to build_offset_ref. If the argument is static,\n> > > > > it'll return it unchanged rather than actually build an OFFSET_REF.\n> > > >\n> > > > If I drop the METHOD_TYPE check, I get an ICE in both splice10.C and splice11.C.\n> > > > splice10.C ICEs when calling `build_offset_ref()` on a static member function (s::get_y).\n> > > > splice11.C ICEs when calling `build_offset_ref()` on a free function (::f).\n> > > >\n> > > > That's why I was initially looking for a way to do this only for non-static members.\n> > >\n> > > I think Jason meant the check for METHOD_TYPE for a BASELINK, which\n> > > is certainly not needed. Please also use BASELINK_P instead of\n> > > TREE_CODE == BASELINK.\n> > >\n> > > We shouldn't call build_offset_ref on static member functions or\n> > > free functions. So I think the second call to build_offset_ref\n> > > should be guarded by\n> > >\n> > > TREE_CODE (op) == FIELD_DECL || DECL_OBJECT_MEMBER_FUNCTION_P (op)\n> > >\n> > > But maybe Jason prefers something else.\n> > >\n> > >\n> > > I would also move the SPLICE_EXPR_ADDRESS_P block after checking\n> > > dependent_splice_p and after check_splice_expr.\n> >\n> > Okay, all of that works. One question:\n> > Would it be more correct to guard the whole block with\n> >\n> > if (SPLICE_EXPR_ADDRESS_P (t))\n> >\n> > or\n> >\n> > if (SPLICE_EXPR_ADDRESS_P (op))\n> >\n> > Given what's in the dependent_splice_p block, I'm thinking latter, but I'm not sure.\n> \n> It should check t, because op won't be a SPLICE_EXPR (except in the\n> dependent_splice_p block).\n> \n> Marek\n> \n\nIn that case, here's the updated patch:\n-- >8 --\nIn case of expressions like `&[:expr:]` where `expr` depends on a\ntemplate parameter, and the splice expression represents a `FIELD_DECL` or\na non-static member `FUNCTION_DECL`, that's exactly what we'd pass on.\nHowever, `build_x_unary_op()` for these expressions is expecting an\n`OFFSET_REF`. `OFFSET_REF` is also what gets passed to\n`build_x_unary_op()` when templates are not involved.\n\nThere's also a difference between the template argument being a type and\nusing `members_of()` to get to the reflections of members (in which case\nevaluating the `SPLICE_EXPR` returns a `FUNCTION_DECL` - `splice10.C`\ntest) and passing `^^T::member` as the template argument (in which case\nevaluating the `SPLICE_EXPR` returns a `BASELINK` - `splice11.C`).\n\nSigned-off-by: Boris Staletic <boris.staletic@protonmail.com>\n\n\tPR c++/123660\n\tPR c++/123661\n\ngcc/cp/ChangeLog:\n\n\t* pt.cc (tsubst_splice_expr): Handle pointers to non-static members\n\tfrom splice expressions\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/reflect/splice10.C: New test.\n\t* g++.dg/reflect/splice11.C: New test.\n---\n gcc/cp/pt.cc | 12 ++++++++++\n gcc/testsuite/g++.dg/reflect/splice10.C | 28 ++++++++++++++++++++++++\n gcc/testsuite/g++.dg/reflect/splice11.C | 29 +++++++++++++++++++++++++\n 3 files changed, 69 insertions(+)\n create mode 100644 gcc/testsuite/g++.dg/reflect/splice10.C\n create mode 100644 gcc/testsuite/g++.dg/reflect/splice11.C", "diff": "diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc\nindex 049bbf07e0..333ecc3130 100644\n--- a/gcc/cp/pt.cc\n+++ b/gcc/cp/pt.cc\n@@ -16771,6 +16771,18 @@ tsubst_splice_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)\n \t\t\t SPLICE_EXPR_MEMBER_ACCESS_P (t),\n \t\t\t (complain & tf_error)))\n return error_mark_node;\n+\n+ if (SPLICE_EXPR_ADDRESS_P (t))\n+ {\n+ if (BASELINK_P (op))\n+\top = build_offset_ref (BINFO_TYPE (BASELINK_ACCESS_BINFO (op)), op,\n+\t\t\t /*address_p=*/true, complain);\n+ else if (TREE_CODE (op) == FIELD_DECL\n+\t || DECL_OBJECT_MEMBER_FUNCTION_P (op))\n+\top = build_offset_ref (DECL_CONTEXT (op), op,\n+\t\t\t /*address_p=*/true, complain);\n+ }\n+\n if (outer_automatic_var_p (op))\n op = process_outer_var_ref (op, complain);\n /* Like in cp_parser_splice_expression, for foo.[: bar :]\ndiff --git a/gcc/testsuite/g++.dg/reflect/splice10.C b/gcc/testsuite/g++.dg/reflect/splice10.C\nnew file mode 100644\nindex 0000000000..2f335ea8fc\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/splice10.C\n@@ -0,0 +1,28 @@\n+// PR c++/123660\n+// PR c++/123661\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+#include <meta>\n+\n+struct s {\n+ int get_z(this s) { return 4; }\n+ static int get_y() { return 4; }\n+ int get_x() { return 3; }\n+ int xx;\n+ static int xxx;\n+};\n+\n+int s::xxx = 5;\n+\n+template<typename T, decltype(0uz) I>\n+constexpr auto test() {\n+ constexpr auto ctx = std::meta::access_context::current();\n+ return &[:members_of(^^T, ctx)[I]:];\n+}\n+\n+static_assert(test<s, 0uz>() == &s::get_z);\n+static_assert(test<s, 1uz>() == &s::get_y);\n+static_assert(test<s, 2uz>() == &s::get_x);\n+static_assert(test<s, 3uz>() == &s::xx);\n+static_assert(test<s, 4uz>() == &s::xxx);\ndiff --git a/gcc/testsuite/g++.dg/reflect/splice11.C b/gcc/testsuite/g++.dg/reflect/splice11.C\nnew file mode 100644\nindex 0000000000..b62fdcc5ee\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/splice11.C\n@@ -0,0 +1,29 @@\n+// PR c++/123660\n+// PR c++/123661\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+#include <meta>\n+\n+void f() {}\n+struct s {\n+ int get_z(this s) { return 4; }\n+ static int get_y() { return 4; }\n+ int get_x() { return 3; }\n+ int xx;\n+ static int xxx;\n+};\n+\n+int s::xxx = 5;\n+\n+template<std::meta::info refl_expr>\n+constexpr auto test() {\n+ return &[:refl_expr:];\n+}\n+\n+static_assert(test<^^s::get_z>() == &s::get_z);\n+static_assert(test<^^s::get_y>() == &s::get_y);\n+static_assert(test<^^s::get_x>() == &s::get_x);\n+static_assert(test<^^s::xx>() == &s::xx);\n+static_assert(test<^^s::xxx>() == &s::xxx);\n+static_assert(test<^^f>() == &f);\n", "prefixes": [ "v3" ] }