[Bug c/100420] New: unspecified VLA bound formatted as [0] instead of [*] in -Wvla-parameter

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 4 16:20:19 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100420

            Bug ID: 100420
           Summary: unspecified VLA bound formatted as [0] instead of [*]
                    in -Wvla-parameter
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The format of the array (VLA) in the note and warning below isn't quite right:
it should match the bound used in the source but instead uses the [0] notation
because [*] and [0] are internally represented the same.

$ cat a.c && gcc -S -Wall a.c
f (int,   int[1][*]);
void f (int n, int[1][n]);

void g (int n, int[1][n]);
void g (int,   int[1][*]);

a.c:2:16: warning: argument 2 of type ‘int[1][n]’ declared as a variable length
array [-Wvla-parameter]
    2 | void f (int n, int[1][n]);
      |                ^~~~~~~~~
a.c:1:16: note: previously declared as an ordinary array ‘int[1][0]’
    1 | void f (int,   int[1][*]);
      |                ^~~~~~~~~
a.c:5:16: warning: argument 2 of type ‘int[1][0]’ declared as an ordinary array
[-Wvla-parameter]
    5 | void g (int,   int[1][*]);
      |                ^~~~~~~~~
a.c:4:16: note: previously declared as a variable length array ‘int[1][n]’
    4 | void g (int n, int[1][n]);
      |                ^~~~~~~~~


More information about the Gcc-bugs mailing list