diff mbox

C++ PATCH for c++/64314 (ICE with value-init and array member)

Message ID 54C268B8.6000803@redhat.com
State New
Headers show

Commit Message

Jason Merrill Jan. 23, 2015, 3:28 p.m. UTC
With my patch for 57510 we are now using build_vec_init for 
sub-CONSTRUCTORs of array type, but we weren't removing the non-constant 
initialization from the CONSTRUCTOR.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 59b7dc8ddf4fdd1505a436dbc4de0499fff9aa41
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jan 23 09:39:53 2015 -0500

    	PR c++/64314
    	PR c++/57510
    	* typeck2.c (split_nonconstant_init_1): Remove a sub-CONSTRUCTOR
    	that has been completely split out.

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index ddd30d1..80a6939 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -653,6 +653,8 @@  split_nonconstant_init_1 (tree dest, tree init)
 
 	      if (!split_nonconstant_init_1 (sub, value))
 		complete_p = false;
+	      else
+		CONSTRUCTOR_ELTS (init)->ordered_remove (idx--);
 	      num_split_elts++;
 	    }
 	  else if (!initializer_constant_valid_p (value, inner_type))
diff --git a/gcc/testsuite/g++.dg/init/array38.C b/gcc/testsuite/g++.dg/init/array38.C
new file mode 100644
index 0000000..bf09774
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array38.C
@@ -0,0 +1,8 @@ 
+// PR c++/64314
+// { dg-do compile { target c++11 } }
+
+struct C { C(); ~C(); };
+struct A {
+  int i;
+  C c[1];
+} a {};