https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127859
Bug ID: 127859
Summary: -Wvla wobbly diagnostic depending on the order of
declarations
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
I don't know whether this is a false positive or a false negative. I think
these are both compatible function types, and thus a false positive, but I
leave that open. The fact is that it diagnoses or not depending on the order
of declarations, which should not happen.
Compare these two files:
alx@debian:~/tmp$ cat arrayp1.c
void f(int (*p)[*]);
void f(int (*p)[ ]);
void f(int p[ ][*]);
void f(int p[ ][ ]);
alx@debian:~/tmp$ gcc -Wall arrayp1.c
arrayp1.c:2:14: warning: mismatch in bound 1 of argument 1 declared as ‘int
(*)[]’ [-Wvla-parameter]
2 | void f(int (*p)[ ]);
| ~~~~~~^~~~~
arrayp1.c:1:14: note: previously declared as ‘int (*)[*]’
1 | void f(int (*p)[*]);
| ~~~~~~^~~~~
arrayp1.c:4:12: error: array type has incomplete element type ‘int[]’
4 | void f(int p[ ][ ]);
| ^
arrayp1.c:4:12: note: declaration of ‘p’ as multidimensional array must have
bounds for all dimensions except the first
alx@debian:~/tmp$ cat arrayp2.c
void f(int p[ ][*]);
void f(int (*p)[ ]);
void f(int (*p)[*]);
void f(int p[ ][ ]);
alx@debian:~/tmp$ gcc -Wall arrayp2.c
arrayp2.c:4:12: error: array type has incomplete element type ‘int[]’
4 | void f(int p[ ][ ]);
| ^
arrayp2.c:4:12: note: declaration of ‘p’ as multidimensional array must have
bounds for all dimensions except the first