https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98588
Bug ID: 98588
Summary: VLA index formatted as <unknown> when it could be
expanded into an expression
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: trivial
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Testing a fix for pr98578 reveals that accesses involving nontrivial indices to
VLAs and pointers to arrays aren't formatted as well as they could: they refer
to "<unknown>" as the index instead formatting the expression as "i + 1". (The
spurious asterisk in the first warning and the missing parentheses in the
second are the subject of pr98587).
$ cat x.c && gcc -O2 -S -Wall x.c
void f (int);
void g (int n, int i)
{
int a[n];
f (a[i + 1]);
}
void h (int n, int i)
{
int (*p)[n] = (int (*)[n])__builtin_malloc (n);
f ((*p)[i + 1]);
}
x.c: In function ‘g’:
x.c:6:3: warning: ‘*a[<unknown>]’ is used uninitialized [-Wuninitialized]
6 | f (a[i + 1]);
| ^~~~~~~~~~~~
x.c: In function ‘h’:
x.c:12:3: warning: ‘*p[<unknown>]’ is used uninitialized [-Wuninitialized]
12 | f ((*p)[i + 1]);
| ^~~~~~~~~~~~~~~