This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/59124] [4.9/5/6 Regression] Wrong warnings "array subscript is above array bounds"
- From: "ssbssa at yahoo dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 29 Mar 2016 19:02:14 +0000
- Subject: [Bug tree-optimization/59124] [4.9/5/6 Regression] Wrong warnings "array subscript is above array bounds"
- Auto-submitted: auto-generated
- References: <bug-59124-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124
--- Comment #37 from Domani Hannes <ssbssa at yahoo dot de> ---
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];
^