https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96290
Bug ID: 96290
Summary: nonsensical bounds in VLA types in -Warray-bounds
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
VLA type mentioned in diagnostics involve nonsensical bounds. The type should
instead be 'char[m][n]'
$ cat z.c && gcc -O2 -S -Wall z.c
#if 1
void f (void*);
void g (int m, int n)
{
char a[m][n];
a[-1][0] = 0;
f (a);
}
z.c: In function ‘g’:
z.c:6:4: warning: array subscript -1 is below array bounds of ‘char[<U1ea0> +
1][<U1cf0> + 1]’ [-Warray-bounds]
6 | a[-1][0] = 0;
| ~^~~~
The C++ front end isn't much better:
z.c: In function ‘void g(int, int)’:
z.c:6:7: warning: array subscript -1 is below array bounds of ‘char
[(<anonymous> + 1)][(<anonymous> + 1)]’ [-Warray-bounds]
6 | a[-1][0] = 0;
| ~~~~^