Patchwork [C++] Fix ICE in build_zero_init_1 (PR c++/56403)

login
register
mail settings
Submitter Jakub Jelinek
Date Feb. 24, 2013, 9:41 p.m.
Message ID <20130224214105.GR1215@tucnak.zalov.cz>
Download mbox | patch
Permalink /patch/222797/
State New
Headers show

Comments

Jakub Jelinek - Feb. 24, 2013, 9:41 p.m.
Hi!

middle-end or back-end created aggregates don't have CLASS_TYPE_P bit set,
so build_zero_init_1 ICEs e.g. on va_list if it is array of structures.

Fixed by treating all RECORD_TYPE or UNION_TYPE types that way, rather than
just CLASS_TYPE_P ones.

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

2013-02-24  Jakub Jelinek  <jakub@redhat.com>

	PR c++/56403
	* init.c (build_zero_init_1): Use RECORD_OR_UNION_CODE_P instead
	of CLASS_TYPE_P.

	* g++.dg/torture/pr56403.C: New test.


	Jakub
Jason Merrill - Feb. 25, 2013, 2:27 p.m.
OK.

Jason

Patch

--- gcc/cp/init.c.jj	2013-02-07 22:27:09.000000000 +0100
+++ gcc/cp/init.c	2013-02-24 20:07:12.246690837 +0100
@@ -179,7 +179,7 @@  build_zero_init_1 (tree type, tree nelts
     init = convert (type, nullptr_node);
   else if (SCALAR_TYPE_P (type))
     init = convert (type, integer_zero_node);
-  else if (CLASS_TYPE_P (type))
+  else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type)))
     {
       tree field;
       vec<constructor_elt, va_gc> *v = NULL;
--- gcc/testsuite/g++.dg/torture/pr56403.C.jj	2013-02-24 20:05:41.961233765 +0100
+++ gcc/testsuite/g++.dg/torture/pr56403.C	2013-02-24 20:05:14.000000000 +0100
@@ -0,0 +1,12 @@ 
+// PR c++/56403
+// { dg-do compile }
+
+#include <stdarg.h>
+
+struct S { va_list err_args; };
+
+void *
+foo ()
+{
+  return new S ();
+}