The following code is compiled without warnings, in spite of 4711 not being defined by enum. If the default-case will be omitted, the expected warning appears.
int main(int argc, char** argv) { enum Enum { a }; Enum test = a; switch(test) { case 4711: break; default: break; } return 0; } -- Summary: switch/case does not detect invalid enum values if default-case is used Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sven dot bornemann at materna dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25995