According to my understanding, variable-length arrays were added in C99, yet clang warns on their use via the -Wvla warning:
void foo(void);
void foo(void)
{
unsigned int size = 123;
char foo[size];
(void)foo;
}
$ clang -Weverything -c -std=c99 test.c
yields:
test.c:5:13: warning: variable length array used [-Wvla]
char foo[size];
I found a test case for -Wvla on this (unofficial) mirror:
https://github.com/llvm-mirror/clang/blob/master/test/Sema/warn-vla.c
This shows that the warning is expected even in C99 mode:
// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify -Wvla %s
// RUN: %clang_cc1 -std=c89 -fsyntax-only -verify -Wvla %s
Is this correct? I notice -Wvla is only enabled by -Weverything, so is it experimental or not properly supported?
Thanks