PR c++/79607 - ICE with T{} initializer
authorJason Merrill <jason@redhat.com>
Mon, 20 Feb 2017 06:06:03 +0000 (01:06 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 20 Feb 2017 06:06:03 +0000 (01:06 -0500)
* decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.

From-SVN: r245592

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

index 8ff836e28d08ee7c1243d8d726da8d754d431160..3ae889317f48b63e92200760c99f287a5fc4d408 100644 (file)
@@ -1,5 +1,8 @@
 2017-02-19  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++/79566 - elaborated-type-specifier in range for
        * parser.c (cp_parser_simple_declaration): Fix check for type
        definition.
index 70c44fbb9f02582377e13c29d5c7d81027820fca..e5c2bab214bcb1e93db111b80db8babc3859e472 100644 (file)
@@ -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 (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;