On Fri, Dec 14, 2012 at 1:04 PM, Martin Jambor <mjam...@suse.cz> wrote: > Hi, > > below are two variants for PR 55355, one for trunk and for 4.7, the > second one, without dumping, for 4.6. On 4.6 they fix an ICE for a > too-large integer on i686, which perhaps can also happen on 4.7 and > trunk even though it does not for their particular testcase. > > I've bootstrapped and tested this on x86_64-linux on trunk and the two > branches, I'm in the process of doing the same on i686-linux. OK for > everywhere if it passes?
Ok. Thanks, Richard. > Thanks, > > Martin > > > trunk and 4.7 variant: > > 2012-12-12 Martin Jambor <mjam...@suse.cz> > > PR tree-optimization/55355 > * tree-sra.c (type_internals_preclude_sra_p): Also check that > bit_position is small enough to fit a single HOST_WIDE_INT. > > * testsuite/g++.dg/torture/pr55355.C: New test. > > > diff --git a/gcc/testsuite/g++.dg/torture/pr55355.C > b/gcc/testsuite/g++.dg/torture/pr55355.C > new file mode 100644 > index 0000000..6d8f8b6 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/torture/pr55355.C > @@ -0,0 +1,23 @@ > +/* { dg-do compile } */ > + > +struct A > +{ > + void funcA(void); > +}; > + > +struct B {}; > + > +struct C > +{ > + void funcC(void) { a_mp->funcA(); } > + > + char buf_ma[268435456]; > + A *a_mp; > + B b_m; > +}; > + > +void > +func(C *c_p) > +{ > + c_p->funcC(); > +} > diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c > index 21d8a51..286ef26 100644 > --- a/gcc/tree-sra.c > +++ b/gcc/tree-sra.c > @@ -714,7 +714,12 @@ type_internals_preclude_sra_p (tree type, const char > **msg) > { > *msg = "structure field size not fixed"; > return true; > - } > + } > + if (!host_integerp (bit_position (fld), 0)) > + { > + *msg = "structure field size too big"; > + return true; > + } > if (AGGREGATE_TYPE_P (ft) > && int_bit_position (fld) % BITS_PER_UNIT != 0) > { > > > 4.6 variant: > > > 2012-12-12 Martin Jambor <mjam...@suse.cz> > > PR tree-optimization/55355 > * tree-sra.c (type_internals_preclude_sra_p): Also check that > bit_position is small enough to fit a single HOST_WIDE_INT. > > * testsuite/g++.dg/torture/pr55355.C: New test. > > Index: gcc/testsuite/g++.dg/torture/pr55355.C > =================================================================== > --- gcc/testsuite/g++.dg/torture/pr55355.C (revision 0) > +++ gcc/testsuite/g++.dg/torture/pr55355.C (revision 0) > @@ -0,0 +1,23 @@ > +/* { dg-do compile } */ > + > +struct A > +{ > + void funcA(void); > +}; > + > +struct B {}; > + > +struct C > +{ > + void funcC(void) { a_mp->funcA(); } > + > + char buf_ma[268435456]; > + A *a_mp; > + B b_m; > +}; > + > +void > +func(C *c_p) > +{ > + c_p->funcC(); > +} > Index: gcc/tree-sra.c > =================================================================== > --- gcc/tree-sra.c (revision 194450) > +++ gcc/tree-sra.c (working copy) > @@ -666,6 +666,7 @@ type_internals_preclude_sra_p (tree type > || !DECL_FIELD_OFFSET (fld) || !DECL_SIZE (fld) > || !host_integerp (DECL_FIELD_OFFSET (fld), 1) > || !host_integerp (DECL_SIZE (fld), 1) > + || !host_integerp (bit_position (fld), 0) > || (AGGREGATE_TYPE_P (ft) > && int_bit_position (fld) % BITS_PER_UNIT != 0)) > return true;