diff mbox

[C++] Fix ICE in cxx_eval_vec_init_1 (PR c++/51619)

Message ID 20111219140646.GF1957@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Dec. 19, 2011, 2:06 p.m. UTC
Hi!

cxx_eval_vec_init_1 starts with:
  if (TREE_CODE (elttype) == ARRAY_TYPE)
    /* We only do this at the lowest level.  */;
  else if (value_init)
    {
      init = something;
    }
  else if (!init)
    {
      init = something_else;
    }

For the ARRAY_TYPE elttype (i.e. multidimensional array) we are
recursing.  If value_init is true, we ignore init, but
if init is originally NULL, we ICE trying to cp_build_array_ref
of NULL.  IMHO in that case we want to also ignore init and the
above code will fill init in the lowest cxx_eval_vec_init_1 recursion
when elttype is no longer ARRAY_TYPE.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2011-12-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/51619
	* semantics.c (cxx_eval_vec_init_1): If init is NULL for
	multidimensional array, just set eltinit to NULL_TREE.

	* g++.dg/cpp0x/pr51619.C: New test.


	Jakub

Comments

Jason Merrill Dec. 19, 2011, 3:35 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

--- gcc/cp/semantics.c.jj	2011-12-19 09:21:01.000000000 +0100
+++ gcc/cp/semantics.c	2011-12-19 10:45:44.498472626 +0100
@@ -7065,7 +7065,7 @@  cxx_eval_vec_init_1 (const constexpr_cal
       if (TREE_CODE (elttype) == ARRAY_TYPE)
 	{
 	  /* A multidimensional array; recurse.  */
-	  if (value_init)
+	  if (value_init || init == NULL_TREE)
 	    eltinit = NULL_TREE;
 	  else
 	    eltinit = cp_build_array_ref (input_location, init, idx,
--- gcc/testsuite/g++.dg/cpp0x/pr51619.C.jj	2011-12-19 10:49:45.128086227 +0100
+++ gcc/testsuite/g++.dg/cpp0x/pr51619.C	2011-12-19 10:49:09.000000000 +0100
@@ -0,0 +1,7 @@ 
+// PR c++/51619
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+struct A { virtual ~A(); };
+struct B { A a[1][1]; } b;
+struct C { A a[3][3]; } c;