This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: enumeration value ... not handled in switch
- To: "'Joerg Faschingbauer'" <jfasch at aon dot at>
- Subject: RE: enumeration value ... not handled in switch
- From: "Schirmer, Hartmut" <SchirmerH at Innovative-Systems dot de>
- Date: Wed, 26 Sep 2001 18:05:02 +0200
- Cc: "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
Hi,
> This is bug #3780. I'll be cleaning up my patch a bit (although it
> won't become less dirty by doing so :-) and submit it. (This won't
> happen before two weeks, though.)
not really the same problem.
In my C code (not C++) I have
enum { A, B, C } x;
switch (x)
{
case A:
case B:
case C:
break;
default:
// strange
abort();
}
The default case is for runtime safty. The variable x may be in an
illegal state (not initialized, corupted, ...)
If I later add a D to the enum I won't get a warning because of
the default case. Changing the code to
switch (x)
{
case A:
case B:
case C:
break;
default attribute(silent):
// strange
abort();
}
enables the compile time analysis so I don't have to wait for
a runtime error.
Hartmut