[cfe-dev] Likely nasty bug with enum constants type

Eli Friedman eli.friedman at gmail.com
Mon Feb 1 06:55:37 PST 2010


On Mon, Feb 1, 2010 at 3:17 AM, Abramo Bagnara <abramo.bagnara at gmail.com> wrote:
> $ cat bug.c
>
> enum {
>  a = 1U,
>  b = a-2
> };
>
> int x[b];
> $ gcc -S -std=c99 -pedantic -W -Wall bug.c
> bug.c:7: error: size of array ‘x’ is negative
> $ ~/llvm/Debug/bin/clang -S -std=c99 -pedantic -W -Wall bug.c
> $
>
> This typescript show that while gcc (as mandated by c99 standard)
> correctly gives int as the type of the enum constant, clang gives it
> unsigned type.
>
> Do you confirm the bug?

Yes; see http://llvm.org/bugs/show_bug.cgi?id=4515 .

-Eli




More information about the cfe-dev mailing list