type_dependent_init_p was overlooking the possibility of a CONSTRUCTOR
with a dependent type, which we can get from T{}.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 060f95851e7f6d6737937b786c0a6b29cda3c454
Author: Jason Merrill <ja...@redhat.com>
Date:   Sun Feb 19 15:40:39 2017 -0800

            PR c++/79607 - ICE with T{} initializer
    
            * decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 70c44fb..e5c2bab 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6662,6 +6662,9 @@ type_dependent_init_p (tree init)
   else if (TREE_CODE (init) == CONSTRUCTOR)
   /* A brace-enclosed initializer, e.g.: int i = { 3 }; ? */
     {
+      if (dependent_type_p (TREE_TYPE (init)))
+       return true;
+
       vec<constructor_elt, va_gc> *elts;
       size_t nelts;
       size_t i;
diff --git a/gcc/testsuite/g++.dg/template/init11.C 
b/gcc/testsuite/g++.dg/template/init11.C
new file mode 100644
index 0000000..ef337c0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/init11.C
@@ -0,0 +1,9 @@
+// PR c++/79607
+// { dg-do compile { target c++11 } }
+
+template<typename T> struct A
+{
+  static const int i = int{T{}};
+};
+
+A<int> a;

Reply via email to