public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-7848] c++: ICE with alias in pack expansion [PR103769]
Date: Mon, 28 Mar 2022 13:37:07 +0000 (GMT)	[thread overview]
Message-ID: <20220328133707.4ED6F385E446@sourceware.org> (raw)

https://gcc.gnu.org/g:07be8f8da4c6840a1fd6b2229b147e50cc6f03dc

commit r12-7848-g07be8f8da4c6840a1fd6b2229b147e50cc6f03dc
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 25 11:26:06 2022 -0400

    c++: ICE with alias in pack expansion [PR103769]
    
    This was breaking because when we stripped the 't' typedef in s<t<Args>...>
    to be s<Args...>, the TYPE_MAIN_VARIANT of "Args..." was still
    "t<Args>...", because type pack expansions are treated as types.  Fixed by
    using the right function to copy a "type".
    
            PR c++/99445
            PR c++/103769
    
    gcc/cp/ChangeLog:
    
            * tree.cc (strip_typedefs): Use build_distinct_type_copy.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/variadic-alias5.C: New test.

Diff:
---
 gcc/cp/tree.cc                               | 2 +-
 gcc/testsuite/g++.dg/cpp0x/variadic-alias5.C | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index eb59e56610b..492921721f2 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -1791,7 +1791,7 @@ strip_typedefs (tree t, bool *remove_attributes, unsigned int flags)
 	      Ts pack, resulting in an error.  */
 	    if (type != pat && uses_parameter_packs (type))
 	      {
-		result = copy_node (t);
+		result = build_distinct_type_copy (t);
 		PACK_EXPANSION_PATTERN (result) = type;
 	      }
 	  }
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-alias5.C b/gcc/testsuite/g++.dg/cpp0x/variadic-alias5.C
new file mode 100644
index 00000000000..70956c91838
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-alias5.C
@@ -0,0 +1,9 @@
+// PR c++/103769
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "--param=hash-table-verification-limit=1000" }
+
+template <typename T> using t = T;
+template <typename...> struct s {};
+template <typename...Args> s<t<Args>...> f() { return {};}
+
+int main() { f<void>(); }


                 reply	other threads:[~2022-03-28 13:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220328133707.4ED6F385E446@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).