re PR c++/64520 (ICE with std::initializer_list)
authorJason Merrill <jason@redhat.com>
Tue, 13 Jan 2015 21:04:28 +0000 (16:04 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 13 Jan 2015 21:04:28 +0000 (16:04 -0500)
PR c++/64520
* pt.c (unify): Don't try to deduce to std::initializer_list<T...>.

From-SVN: r219557

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/initlist91.C [new file with mode: 0644]

index 14e1fb323c26f9e174b4eedb2262ca37c1b97b4b..0e94fe136a4c0194870dfa7e4b18a13013b9cb76 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/64520
+       * pt.c (unify): Don't try to deduce to std::initializer_list<T...>.
+
 2015-01-12  Jason Merrill  <jason@redhat.com>
 
        PR c++/64547
index d8652fb3d21430101d75f8c228b122968684da61..3ac93db948a3086574fe8f653e1790ec57f24718 100644 (file)
@@ -17854,7 +17854,13 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
       if (TREE_CODE (parm) == ARRAY_TYPE)
        elttype = TREE_TYPE (parm);
       else
-       elttype = TREE_VEC_ELT (CLASSTYPE_TI_ARGS (parm), 0);
+       {
+         elttype = TREE_VEC_ELT (CLASSTYPE_TI_ARGS (parm), 0);
+         /* Deduction is defined in terms of a single type, so just punt
+            on the (bizarre) std::initializer_list<T...>.  */
+         if (PACK_EXPANSION_P (elttype))
+           return unify_success (explain_p);
+       }
 
       FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (arg), i, elt)
        {
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist91.C b/gcc/testsuite/g++.dg/cpp0x/initlist91.C
new file mode 100644 (file)
index 0000000..1387557
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/64520
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+struct A {
+  template <typename... B> A(std::initializer_list<B...>);
+};
+A a { 0 };                     // { dg-error "" }