Hi, Below sample program produced wrong code in g++ version 4.1.1. Is this a bug or am I violating C++ standard? (not taking range propagation into account?) $ cat test.c #include <stdio.h> typedef enum QUARTET { PIANO = -1, VIOLIN, VIOLA, CELLO } Quartet; enum { FOURTY_TWO = 42 }; char * getstring(Quartet q) { char *p; int i = (int)q; switch (i) { case PIANO: p = "piano"; break; case VIOLIN: p = "violin"; break; case VIOLA: p = "viola"; break; case CELLO: p = "cello"; break; case FOURTY_TWO: p = "42"; break; default: p = "unknown"; break; } return p; } int main() { Quartet q = VIOLIN; printf("instrument: %s\n", getstring(q)); printf("instrument: %s\n", getstring((Quartet) FOURTY_TWO)); printf("instrument: %s\n", getstring((Quartet) 129)); return 0; } $ g++ --version g++ (GCC) 4.1.1 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ -O2 -o test test.c && ./test instrument: violin instrument: unknown instrument: unknown My expected result is: instrument: violin instrument: 42 instrument: unknown I've seen the problem going away if: - compiled with gcc (not g++) - add -fno-tree-dominator-opts option - set Quartet type `PIANO = ' to greater than or equal to zero - compile with g++ version 3.4 serise Any hint please? Best Regards, (Hiroki Kaminaga) t --