When I compile the code "int array[4.3];", in addition to the error, GCC also emits a -Wvla warning saying that ISO C90 forbids this. However, I specify -std=c11 in the command line, and IMHO this is at least an inconsistency between errors and error messages. $: cat t.c int array[4.3]; $: gcc-trunk -c -Wvla -std=c11 -pedantic t.c t.c:1:5: error: size of array ‘array’ has non-integer type int array[4.3]; ^ t.c:1:1: warning: variably modified ‘array’ at file scope int array[4.3]; ^ t.c:1:1: warning: ISO C90 forbids array ‘array’ whose size can’t be evaluated [-Wvla] $: gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror --with-gmp=/usr/local/gcc-trunk --with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk --with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk Thread model: posix gcc version 6.0.0 20150815 (experimental) [trunk revision 226911] (GCC) $:
It is also useless to give such warning after such error. I'm afraid the way GCC reports most extensions is very fragile in this way. It doesn't affect only Wvla. It would be nice to discuss/design/agree on a canonical and future-proof way to report: * Pure GNU extensions, not accepted by any standard. * Features accepted by some standard but that are extensions for other standards (like C++ style comments). The latter requires some future-proof way of reporting: * Extensions that are forbidden up to a particular standard. * Extensions that were accepted but are forbidden now (not sure if there is such case at all). (It is kind of ironic that Clang is fair more clear pointing out when something is a "GNU extension". In some way, Clang is doing more promotion of GNU than GCC!)
Moreover, since VLAs are not an extension in C99, the text of Wvla is wrong always for -std=c99. void square(int num) { int array[num]; } With -std=c99 -Wpedantic there is no warning. With -std=c99 -Wvla, it mentions ISO C90, which is irrelevant. Clang just says: "variable length array used"
*** Bug 67237 has been marked as a duplicate of this bug. ***
*** Bug 67236 has been marked as a duplicate of this bug. ***
*** Bug 67235 has been marked as a duplicate of this bug. ***
*** Bug 67234 has been marked as a duplicate of this bug. ***
*** Bug 67233 has been marked as a duplicate of this bug. ***
*** Bug 67232 has been marked as a duplicate of this bug. ***
*** Bug 67231 has been marked as a duplicate of this bug. ***
*** Bug 67230 has been marked as a duplicate of this bug. ***
(In reply to Marek Polacek from comment #10) > *** Bug 67230 has been marked as a duplicate of this bug. *** Sorry, Marek. I did not realize that I had submitted so many duplicate reports. I got gateway errors from GCC bugzilla that night when I was submitting this bug report. I tried several times and it seems they all went through despite the errors.
No problem. I suspected it was something like that.
Another case is -Wdeclaration-after-statement: int fn (int m) { if (m > 0) return -1; int a; }
*** Bug 71925 has been marked as a duplicate of this bug. ***