https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84053
Bug ID: 84053
Summary: missing -Warray-bounds accessing a struct array member
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Prior to version 4.7, GCC would diagnose out-of-bounds accesses to local arrays
across inlined function boundaries. The test case below shows that these
invalid accesses are no longer diagnosed.
int f (int i)
{
int a[] = { 1, 2 };
if (i < 3)
i = 3;
return a[i]; // -Warray-bounds (good)
}
int g (const int *p, int i)
{
return p[i];
}
int h (int i)
{
int a[] = { 2, 3 };
if (i < 3)
i = 3;
return g (a, i); // missing -Warray-bounds
}
t.c: In function ‘f’:
t.c:8:11: warning: array subscript 3 is above array bounds of ‘int[2]’
[-Warray-bounds]
return a[i]; // -Warray-bounds (good)
~^~~