[cfe-dev] clang bug: constant array size is recognized as variable array size

Eli Friedman eli.friedman at gmail.com
Fri May 23 03:58:47 PDT 2008


On Fri, May 23, 2008 at 3:17 AM, Csaba Hruska <csaba.hruska at gmail.com> wrote:
> Hi!
> It's me again ;)
> I've found an another bug.
>
> gcc accepts it, but clang thows this:
>     error: variable length array declared outside of any function
>
> I'v compiled it with clang svn revision 51478.
>
> code:
> #define C1 100.
> #define C2 120.
>
> typedef struct
> {
>   int A [(unsigned int)(C1*C2)];
> } s_t;

gcc is wrong here; "(unsigned int)(100.*120.)" isn't an integer
constant expression (per the definition in C99 6.6), so A is in fact
an illegal VLA per the standard. Not sure what to do here.

-Eli



More information about the cfe-dev mailing list