http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55079



--- Comment #14 from Jan Hubicka <hubicka at ucw dot cz> 2012-12-10 16:26:40 
UTC ---

> 

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55079

> 

> --- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-10 
> 14:14:07 UTC ---

> (In reply to comment #9)

> > This is reduced testcase from gcov.c

> > int a[8];

> > int

> > t (void)

> > {

> >   int ix = 0;

> >   int k;

> >   int b = 0;

> >   int curr = 0;

> >   for (k = 0; k < 2; k++)

> >     {

> >       b = ix * 32;

> >       curr = a[ix++];

> >       if (!(ix <= 8))

> 

> See below.

> 

> >         abort ();

> > 

> >       while (curr)

> >         {

> >           b = ix * 32;

> >           curr = a[ix++];

> >           if (!(ix <= 8))

> 

> This is a test after the fact.  For ix == 8 we will still enter the

> next loop iteration (GCC can't know anything about 'curr') and thus

> access a[8] which is out-of-bounds.

> 

> Fixing the tests to test < 8 instead fixes the warnings.

> 

> This testcase is invalid.



I fixed that in GCOV sources already, but it depends on the definition of

invalidness.  In general construct like ix <= some_constant may come from some

unrelated stuff (macro expansion) and may be fully redundant in sane and valid

program. In that case waring after unrolling some_constant times there will be

out of bound access (without explicitely saying that unrolling is needed) is

undesirable IMO.  The loop has other exit that takes care of the proper bound.



Honza

Reply via email to