]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/79607 - ICE with T{} initializer
authorJason Merrill <jason@redhat.com>
Mon, 18 Sep 2017 18:34:03 +0000 (14:34 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 18 Sep 2017 18:34:03 +0000 (14:34 -0400)
* decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.

From-SVN: r252939

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/template/init11.C [new file with mode: 0644]

index f78bce6be987f8d545148888a7ef66c31490f316..7cfae4e9563983920a5003f62b153ae223eaa1d9 100644 (file)
@@ -1,5 +1,8 @@
 2017-09-18  Jason Merrill  <jason@redhat.com>
 
+       PR c++/79607 - ICE with T{} initializer
+       * decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.
+
        PR c++/72457
        * init.c (expand_aggr_init_1): Only handle value-init of bases.
        * constexpr.c (build_data_member_initialization): Handle multiple
index 04f1c711b0cda40dfa92f3bfb2dd44c0ca859473..3472d29afad0902e1e1e50d8a7e31ea3de597b2e 100644 (file)
@@ -6349,6 +6349,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 (file)
index 0000000..ef337c0
--- /dev/null
@@ -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;