[cfe-dev] -Wvla triggered even for C99 code

Michael Weller (BLOOMBERG/ LONDON) via cfe-dev cfe-dev at lists.llvm.org
Wed Dec 2 07:33:57 PST 2015

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];

$ clang -Weverything -c -std=c99 test.c


test.c:5:13: warning: variable length array used [-Wvla]
    char foo[size];

I found a test case for -Wvla on this (unofficial) mirror:


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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151202/01a188ae/attachment.html>

More information about the cfe-dev mailing list