This is a copy of a Debian report that I made (I thought I might as well report it directly here too): http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=496965
g++ generates bad code for this program on an amd64 machine. It works with fine in 64-bit and with older versions of gcc. #include <stdlib.h> struct MyTypes { enum Type { NOVALUE = 1, VALUE = 30, VALUE2 = 31, VALUE3 = -3 }; static bool isValue(MyTypes::Type value); }; bool MyTypes::isValue(MyTypes::Type value) { switch (value) { case MyTypes::VALUE: case MyTypes::VALUE2: case MyTypes::VALUE3: { return true; } default: { return false; } } } int main(int argc, char *argv[]) { if (true == MyTypes::isValue(MyTypes::Type(32))) { abort(); } return 0; } [EMAIL PROTECTED]:~$ g++ -m32 -Wall -o e enumtest.cpp [EMAIL PROTECTED]:~$ ./e Aborted [EMAIL PROTECTED]:~$ g++ -Wall -o e enumtest.cpp [EMAIL PROTECTED]:~$ ./e [EMAIL PROTECTED]:~$ g++-4.2 -m32 -Wall -o e enumtest.cpp [EMAIL PROTECTED]:~$ ./e [EMAIL PROTECTED]:~$ g++-4.1 -m32 -Wall -o e enumtest.cpp [EMAIL PROTECTED]:~$ ./e It works with -O2 though (not -O1): [EMAIL PROTECTED]:~$ g++ -O2 -m32 -Wall -o e enumtest.cpp [EMAIL PROTECTED]:~$ ./e -- System Information: Debian Release: lenny/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable') Architecture: amd64 (x86_64) -- Summary: bad code generation with enum and -m32 Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gmorin1 at bloomberg dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37281