From: Marek Polacek <polacek@redhat.com>
To: Jason Merrill <jason@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] c++: ICE with generic lambda and pack expansion [PR115425]
Date: Mon, 17 Jun 2024 14:17:29 -0400 [thread overview]
Message-ID: <20240617181729.33445-1-polacek@redhat.com> (raw)
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
-- >8 --
In r13-272 we hardened the *_PACK_EXPANSION and *_ARGUMENT_PACK macros.
That trips up here because make_pack_expansion returns error_mark_node
and we access that with PACK_EXPANSION_LOCAL_P.
PR c++/115425
gcc/cp/ChangeLog:
* pt.cc (tsubst_pack_expansion): Return error_mark_node if
make_pack_expansion doesn't work out.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/lambda-generic12.C: New test.
---
gcc/cp/pt.cc | 2 ++
gcc/testsuite/g++.dg/cpp2a/lambda-generic12.C | 25 +++++++++++++++++++
2 files changed, 27 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp2a/lambda-generic12.C
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 607753ae6b7..e676372f75b 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -13775,6 +13775,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
else
result = tsubst (pattern, args, complain, in_decl);
result = make_pack_expansion (result, complain);
+ if (result == error_mark_node)
+ return error_mark_node;
PACK_EXPANSION_LOCAL_P (result) = PACK_EXPANSION_LOCAL_P (t);
PACK_EXPANSION_SIZEOF_P (result) = PACK_EXPANSION_SIZEOF_P (t);
if (PACK_EXPANSION_AUTO_P (t))
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-generic12.C b/gcc/testsuite/g++.dg/cpp2a/lambda-generic12.C
new file mode 100644
index 00000000000..219529c7c32
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-generic12.C
@@ -0,0 +1,25 @@
+// PR c++/115425
+// { dg-do compile { target c++20 } }
+
+using size_t = decltype(sizeof(0));
+
+template <int... I>
+struct X {};
+
+template<int... Is>
+void foo(X<Is...>);
+
+template<auto>
+struct S;
+
+template<class T>
+auto test() {
+ constexpr static auto x = foo<X<__integer_pack (0)...>>(); // { dg-error "no matching function" }
+ return []<size_t... Is>(X<Is...>) {
+ (typename S<x[Is]>::type{}, ...);
+ }(X<__integer_pack (0)...>{});
+}
+
+int main() {
+ test<int>();
+}
base-commit: b63c7d92012f92e0517190cf263d29bbef8a06bf
--
2.45.1
next reply other threads:[~2024-06-17 18:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 18:17 Marek Polacek [this message]
2024-06-25 2:12 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240617181729.33445-1-polacek@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).