diff mbox

[pph] Fix GC ICE in g++.dg/pph/c1eabi.cc (issue4607047)

Message ID 20110613190859.4B66E1DA1CC@topo.tor.corp.google.com
State New
Headers show

Commit Message

Diego Novillo June 13, 2011, 7:08 p.m. UTC
We were running into a GC ICE because when reading a sorted_fields_type
field we were never setting the lenght of the vector.

This patch moves the setting of the vector length to the actual
allocation function (sorted_fields_type_new).  It was being done in
finish_struct_1 before, so vectors read from the streamer were getting
garbage in the len field.

This fixes g++.dg/pph/c1eabi.{cc,h}.  Tested on x86_64.  Committed to
branch.


Diego.


cp/ChangeLog.pph

	* class.c (sorted_fields_type_new): Set field LEN in the
	newly allocated vector.
	(finish_struct_1): Remove setting of FIELD_VEC->LEN.

testsuite/ChangeLog.pph

	* g++.dg/pph/c1eabi1.h: Remove XFAIL markers.
	* g++.dg/pph/c1eabi1.cc: Likewise.
	Add assembly mis-comparison expectation.


--
This patch is available for review at http://codereview.appspot.com/4607047
diff mbox

Patch

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 86ec04b..70a3668 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5579,8 +5579,12 @@  determine_key_method (tree type)
 struct sorted_fields_type *
 sorted_fields_type_new (int n)
 {
-  return ggc_alloc_sorted_fields_type (sizeof (struct sorted_fields_type)
-				       + n * sizeof (tree));
+  struct sorted_fields_type *sft;
+  sft = ggc_alloc_sorted_fields_type (sizeof (struct sorted_fields_type)
+				      + n * sizeof (tree));
+  sft->len = n;
+
+  return sft;
 }
 
 
@@ -5714,7 +5718,6 @@  finish_struct_1 (tree t)
   if (n_fields > 7)
     {
       struct sorted_fields_type *field_vec = sorted_fields_type_new (n_fields);
-      field_vec->len = n_fields;
       add_fields_to_record_type (TYPE_FIELDS (t), field_vec, 0);
       qsort (field_vec->elts, n_fields, sizeof (tree),
 	     field_decl_cmp);
diff --git a/gcc/testsuite/g++.dg/pph/c1eabi1.cc b/gcc/testsuite/g++.dg/pph/c1eabi1.cc
index 6271501..b2e9b11 100644
--- a/gcc/testsuite/g++.dg/pph/c1eabi1.cc
+++ b/gcc/testsuite/g++.dg/pph/c1eabi1.cc
@@ -1,7 +1,4 @@ 
-// { dg-xfail-if "ICE" { "*-*-*" } { "-fpph-map=pph.map" } }
-// { dg-bogus "mathcalls.h:365:1: internal compiler error: Segmentation fault" "" { xfail *-*-* } 0 }
-// { dg-prune-output "In file included from " }
-// { dg-prune-output "                 from " }
 // { dg-options "-w -fpermissive" }
+// pph asm xdiff
 
 #include "c1eabi1.h"
diff --git a/gcc/testsuite/g++.dg/pph/c1eabi1.h b/gcc/testsuite/g++.dg/pph/c1eabi1.h
index 151b768..5f5b593 100644
--- a/gcc/testsuite/g++.dg/pph/c1eabi1.h
+++ b/gcc/testsuite/g++.dg/pph/c1eabi1.h
@@ -1,7 +1,3 @@ 
-// { dg-xfail-if "ICE" { "*-*-*" } { "-fpph-map=pph.map" } }
-// { dg-bogus "mathcalls.h:365:1: internal compiler error: Segmentation fault" "" { xfail *-*-* } 0 }
-// { dg-prune-output "In file included " }
-// { dg-prune-output "                 from " }
 // { dg-options "-w -fpermissive" }
 
 #ifndef __PPH_GUARD_H