[Bug c/71925] New: poor -Wvla phrasing in C99 mode and later, documentation misleading
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jul 19 03:29:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71925
Bug ID: 71925
Summary: poor -Wvla phrasing in C99 mode and later,
documentation misleading
Product: gcc
Version: 7.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: ---
This report points out two minor problems with the -Wvla warning:
1) The text of the warning says that "ISO C90 forbids variable length array."
That is relevant in C90 mode but not in C99 or C11 modes. In those modes (and
for simplicity's sake, perhaps also in C90 mode) the warning should simply say
that a VLA has been declared.
$ cat walloca.c && /build/gcc-walloca/gcc/xgcc -B /build/gcc-walloca/gcc -S
-Wvla walloca.c
void f (int n)
{
int a [n];
(void)a;
}
walloca.c: In function ‘f’:
walloca.c:3:3: warning: ISO C90 forbids variable length array ‘a’ [-Wvla]
int a [n];
^~~
2) The manual states this about the option:
Warn if variable length array is used in the code. -Wno-vla prevents the
-Wpedantic warning of the variable length array.
Yet the warning is only enabled by -Wpedantic in C90 mode and not in C99 or C11
modes. Since C11 is the default mode, the documentation is misleading and the
interaction of -Wpedantic, -Wvla, and the language mode should be clarified.
$ cat walloca.c && /build/gcc-walloca/gcc/xgcc -B /build/gcc-walloca/gcc -S
-Wall -Wextra -Wpedantic walloca.c
void f (int n)
{
int a [n];
(void)a;
}
$
More information about the Gcc-bugs
mailing list