Calling finish_compound_literal in this case ends up trying to reshape an initializer that has already been digested, and removing the call doesn't seem to break anything.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 6f94e657ce04fd32cac5e616e9ca675c40e3fab5
Author: Jason Merrill <ja...@redhat.com>
Date:   Sun Jul 13 13:53:24 2014 -0400

    	PR c++/58611
    	* decl.c (check_initializer): Don't finish_compound_literal
    	on erroneous constexpr init.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8f829d0..9d3fbb2 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5812,11 +5812,8 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
 	      /* Declared constexpr, but no suitable initializer; massage
 		 init appropriately so we can pass it into store_init_value
 		 for the error.  */
-	      if (init && BRACE_ENCLOSED_INITIALIZER_P (init))
-		init = finish_compound_literal (type, init,
-						tf_warning_or_error);
-	      else if (CLASS_TYPE_P (type)
-		       && (!init || TREE_CODE (init) == TREE_LIST))
+	      if (CLASS_TYPE_P (type)
+		  && (!init || TREE_CODE (init) == TREE_LIST))
 		{
 		  init = build_functional_cast (type, init, tf_none);
 		  if (TREE_CODE (init) == TARGET_EXPR)
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C
new file mode 100644
index 0000000..16eacdd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array6.C
@@ -0,0 +1,15 @@
+// PR c++/58611
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  int i;
+  constexpr A() {}		// { dg-error "A::i" }
+};
+
+struct B
+{
+  A a;
+};
+
+constexpr B b[] = { {} };	// { dg-error "A::A" }

Reply via email to