* C++ PATCH for c++/64520 (ICE with std::initializer_list<T...>)
@ 2015-01-13 20:43 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2015-01-13 20:43 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 162 bytes --]
The special rules for deduction of std::initializer_list don't support a
pack expansion, but we shouldn't crash.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 64520.patch --]
[-- Type: text/x-patch, Size: 1308 bytes --]
commit a1607c38aaf6e04c2a601ee78dca67984e179986
Author: Jason Merrill <jason@redhat.com>
Date: Mon Jan 12 13:27:20 2015 -0500
PR c++/64520
* pt.c (unify): Don't try to deduce to std::initializer_list<T...>.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d8652fb..3ac93db 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 0000000..1387557
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist91.C
@@ -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 "" }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-01-13 20:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13 20:43 C++ PATCH for c++/64520 (ICE with std::initializer_list<T...>) Jason Merrill
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).