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.

>             abort ();
>         }
>     }
>   return curr + b;
> }
> 
> jan@linux-e0ml:~/trunk/build/gcc> ./xgcc -B ./ -O2 -fprofile-use t.c
> -Warray-bounds -S -S -fdump-tree-cunroll-details  -fdump-tree-all-details  
> t.c: In function ‘t’:
> t.c:14:2: warning: incompatible implicit declaration of built-in function
> ‘abort’ [enabled by default]
>   abort ();
>   ^
> t.c:25:1: note: file /home/jan/trunk/build/gcc/t.gcda not found, execution
> counts estimated
>  }
>  ^
> t.c:19:15: warning: array subscript is above array bounds [-Warray-bounds]
>        curr = a[ix++];
>                ^
> t.c:19:15: warning: array subscript is above array bounds [-Warray-bounds]
> 
> Obivously here unroller does not know that bv_ix is at least 1

Reply via email to