On Fri, Jul 22 2016, Julia Lawall wrote: > > In C, enums are ints. Is there a Gcc option that checks them? For > example, the following program compiles fine with -Wall: > > enum one {ONE=1, TWO=2, THREE=3}; > enum two {ONEX=7, TWOX=8, THREEX=9}; > > int f (int x) { > enum one o = ONE; > enum two t = THREEX; > if (x) o = t; else t = o; > return 0; > } However with this slight change (and line-numbers added for clarity) 1 2 enum one {ONE=1, TWO=2, THREE=3} __attribute((bitwise)); 3 enum two {ONEX=7, TWOX=8, THREEX=9} __attribute((bitwise)); 4 5 int f (int x) { 6 enum one o = ONE; 7 enum two t = THREEX; 8 if (x) o = t; else t = o; 9 return 0; 10 } sparse complains: /tmp/test.c:8:14: warning: mixing different enum types /tmp/test.c:8:14: int enum two versus /tmp/test.c:8:14: int enum one /tmp/test.c:8:26: warning: mixing different enum types /tmp/test.c:8:26: int enum one versus /tmp/test.c:8:26: int enum two Is that what you were hoping for? NeilBrown