This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH, middle-end] Fix PR 37861 - Bogus array bounds warning
On Wed, Nov 05, 2008 at 12:03:36PM +0100, Martin Jambor wrote:
> On Wed, Nov 05, 2008 at 10:56:27AM +0100, Richard Guenther wrote:
> > On Wed, 5 Nov 2008, Martin Jambor wrote:
> > > the following patch gets rid of the bogus warning.
> > >
> > > The problem is, that fwprop currently generates array_refs of the form
> > > &(*formatstr_3(D))[cumulative_offset] for multidimensional arrays and
> > > the cumulative offset can then naturally be bigger than the respective
> > > dimension of the array.
> > >
> > > This happens because, when multidimensional arrays are passed as a
> > > formal parameter, they are gimplified into a pointer, thus
> > > formatstr becomes char * formatstr. We do not want to
> > > be doing the transformation on such variables and the patch inhibits
> > > them.
> > >
> > > I have bootstrapped and regression tested it on x86_64-suse-linux
> > > (revision 141561). I hope this won't cause any performance problems.
> > >
> > > OK for trunk?
> > This is ok if you add both testcases from the PR and add a brief
> > comment before the INDIRECT_REF check in the patch.
> I originally intended to include the testcases but somehow forgot in
> the end. This is the updated patch, I will commit it in a few hours,
> unless someone objects.
> 2008-11-05 Martin Jambor <email@example.com>
> PR middle-end/37861
> * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Don't turn
> pointer arithmetics into array_ref if the array is accessed
> through an indirect_ref.
> * testsuite/gcc.dg/Warray-bounds-5.c: New file.
> * testsuite/gcc.dg/Warray-bounds-6.c: New file.
Committed as revision 141613, except that I committed the testsuite
Changelog entries to the testsuite Changelog file.