{"id":2226952,"url":"http://patchwork.ozlabs.org/api/patches/2226952/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260422220620.2017820-1-polacek@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","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":"<20260422220620.2017820-1-polacek@redhat.com>","list_archive_url":null,"date":"2026-04-22T22:06:20","name":"c++/reflection: erroneous access check on dependent splice [PR124989]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"b510f7b48fe751f6ced8941984da4442288cdaf4","submitter":{"id":14370,"url":"http://patchwork.ozlabs.org/api/people/14370/?format=json","name":"Marek Polacek","email":"polacek@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260422220620.2017820-1-polacek@redhat.com/mbox/","series":[{"id":501121,"url":"http://patchwork.ozlabs.org/api/series/501121/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=501121","date":"2026-04-22T22:06:20","name":"c++/reflection: erroneous access check on dependent splice [PR124989]","version":1,"mbox":"http://patchwork.ozlabs.org/series/501121/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2226952/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2226952/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=ZLON37s2;\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=ZLON37s2","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 4g1Cyg6qc3z1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 08:07:54 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 588864B99F4D\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 22:07:52 +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 BADD54BBCDFB\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 22:06:37 +0000 (GMT)","from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-454-jJUHIZBlOni9U3joHQwjLA-1; Wed,\n 22 Apr 2026 18:06:35 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id E6AB41955F3D\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 22:06:34 +0000 (UTC)","from pdp-11.redhat.com (unknown [10.22.80.162])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 365A019560B6; Wed, 22 Apr 2026 22:06:34 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 588864B99F4D","OpenDKIM Filter v2.11.0 sourceware.org BADD54BBCDFB"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org BADD54BBCDFB","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org BADD54BBCDFB","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776895597; cv=none;\n b=u5wG6HBDRPh++K24TIr5TcXKCnrjBBEhHjfWPiulNLd8h08HZRxFgRCwPlUWcQ1Rf8UnD+0UW19zkgfbxmC/G1oZyP59n4Ubaofu2i+Gvv4nE8kmAExrQkci5J9nkhT5XdIBeUKuDSJPkq7PhbotKInOPhkHVePHnxv/CGmk9lI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776895597; c=relaxed/simple;\n bh=Hkj+9MJ+dKv7Ri6yHp//hRhojPtNaudYxG4fcFGmdEI=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=O/jJXmaY1rMQQd8UlXA5N+983XOVS8pC4WvNjxdwD+Ls8eJV5P9Vn5m0od7+Xhfw4J8M8+wHH/ty05cOF0/ELE2njqkNEc2bBv14hsNKLDZNBru0+GuSl33oVWYg7U65vYcgfQIIwxJiFlomn7gZkaM/2xSEaaTzEdKnN6qZavI=","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=1776895597;\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=lvm9Mg4//oBXOKQQdYqMD73RVtCvXSzS+0cxtifJAxU=;\n b=ZLON37s2lpBV6gKJ/9oxNOlFzd7fJvLri3SesD8hJO+5bJhtspwcmdlqqWs1cQD9Pz3kqH\n iBQaKr0M8kt1+SJ2ewtFwrr18XBlleErFgLvdyfYu5syBApj2Oh3Pfr4KRox+nCCYlWMvF\n 3N7CGiZCTQeG1zAue24RDTz0VGNK5Fc=","X-MC-Unique":"jJUHIZBlOni9U3joHQwjLA-1","X-Mimecast-MFC-AGG-ID":"jJUHIZBlOni9U3joHQwjLA_1776895595","From":"Marek Polacek <polacek@redhat.com>","To":"GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>,\n Patrick Palka <ppalka@redhat.com>, Jakub Jelinek <jakub@redhat.com>","Subject":"[PATCH] c++/reflection: erroneous access check on dependent splice\n [PR124989]","Date":"Wed, 22 Apr 2026 18:06:20 -0400","Message-ID":"<20260422220620.2017820-1-polacek@redhat.com>","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":"4tCqoAKuV9GPt2xVOpb0pWdBv7AO7YIieAw5UFJf79o_1776895595","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 dg.exp on x86_64-pc-linux-gnu, ok for trunk/16.2?\n\nThough, I'd like to push this to 16.1 if possible, it seems\nsafe and looks relatively important.\n\n-- >8 --\nWhen processing &[:R:] in cp_parser_splice_expression, we call\nbuild_offset_ref with access checking turned off via push_ and\npop_deferring_access_checks, but the same pair of calls is not\npresent around the call to build_offset_ref in tsubst_splice_expr\nand so the following test fails to compile due to access control\nchecking failures.\n\n\tPR c++/124989\n\ngcc/cp/ChangeLog:\n\n\t* pt.cc (tsubst_splice_expr): Turn off access checking for the\n\tbuild_offset_ref call.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/reflect/member24.C: New test.\n---\n gcc/cp/pt.cc                            |  2 ++\n gcc/testsuite/g++.dg/reflect/member24.C | 25 +++++++++++++++++++++++++\n 2 files changed, 27 insertions(+)\n create mode 100644 gcc/testsuite/g++.dg/reflect/member24.C\n\n\nbase-commit: b6e40cf38c60d11c4e105f9179a6d5cfb502bd9b","diff":"diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc\nindex 5d97ca7997f..7e755193f4e 100644\n--- a/gcc/cp/pt.cc\n+++ b/gcc/cp/pt.cc\n@@ -16957,12 +16957,14 @@ tsubst_splice_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)\n \n   if (SPLICE_EXPR_ADDRESS_P (t))\n     {\n+      push_deferring_access_checks (dk_no_check);\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 (DECL_NONSTATIC_MEMBER_P (op))\n \top = build_offset_ref (DECL_CONTEXT (op), op,\n \t\t\t       /*address_p=*/true, complain);\n+      pop_deferring_access_checks ();\n     }\n \n   if (outer_automatic_var_p (op))\ndiff --git a/gcc/testsuite/g++.dg/reflect/member24.C b/gcc/testsuite/g++.dg/reflect/member24.C\nnew file mode 100644\nindex 00000000000..461b8b35f30\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/reflect/member24.C\n@@ -0,0 +1,25 @@\n+// PR c++/124989\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+using info = decltype(^^::);\n+\n+template <info R>\n+constexpr auto pointer_of()\n+{\n+  return &[: R :];\n+}\n+\n+struct X\n+{\n+    int a;\n+protected:\n+    int b;\n+private:\n+    int c;\n+\n+public:\n+    static constexpr auto pa = pointer_of<^^X::a>();\n+    static constexpr auto pb = pointer_of<^^X::b>();\n+    static constexpr auto pc = pointer_of<^^X::c>();\n+};\n","prefixes":[]}