This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: enumeration value ... not handled in switch


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]