[cfe-dev] clang bug: constant array size is recognized as variable array size
Neil Booth
neil at daikokuya.co.uk
Fri May 23 05:37:58 PDT 2008
Eli Friedman wrote:-
> 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.
Agreed. I see little reason to accept it; it's not hard to fix in the
source.
Neil.
More information about the cfe-dev
mailing list