[Bug tree-optimization/59124] [4.9/5/6 Regression] Wrong warnings "array subscript is above array bounds"
ppalka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 30 01:04:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124
--- Comment #39 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Domani Hannes from comment #37)
> With the new patch there is still a warning with this example:
> =============== 8< ===============
> int f(void);
>
> int test(void)
> {
> int baz[4];
> int q = 0;
> int d, i, j, sum;
>
> for (i = 0; i < 2; i++)
> {
> d = f();
>
> if (d == 3)
> {
> baz[q] = d;
> q++;
> if (q == 4) break;
> }
> }
>
> sum = 0;
> for (i = 0; i < q; i++)
> {
> for (j = i + 1; j < q; j++)
> {
> sum += baz[j];
> }
> }
>
> return (sum);
> }
> =============== >8 ===============
> $ gcc -O3 -Wall -S q.c
> q.c: In function 'test':
> q.c:27:17: warning: array subscript is above array bounds [-Warray-bounds]
> sum += baz[j];
> ^
Thanks, I'll check it out. Seems to be a regression from 4.7 as well.
More information about the Gcc-bugs
mailing list