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

Abramo Bagnara abramo.bagnara at gmail.com
Mon Feb 1 03:17:12 PST 2010


$ 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?



More information about the cfe-dev mailing list