c++: ICE with alias in pack expansion [PR103769]
authorJason Merrill <jason@redhat.com>
Fri, 25 Mar 2022 15:26:06 +0000 (11:26 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 28 Mar 2022 13:35:58 +0000 (09:35 -0400)
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.

gcc/cp/tree.cc
gcc/testsuite/g++.dg/cpp0x/variadic-alias5.C [new file with mode: 0644]

index eb59e56..4929217 100644 (file)
@@ -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 (file)
index 0000000..70956c9
--- /dev/null
@@ -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>(); }