This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: enumeration value ... not handled in switch
- From: Daniel Brockman <daniel at brockman dot se>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 11 Jan 2005 06:50:05 +0100
- Subject: Re: enumeration value ... not handled in switch
- References: <1F5C7ECB324CD411B58600D0B723F181779402@oehhex01.becker.de> <87k6qkr0nt.fsf@wigwam.deepwood.net>
Daniel Brockman <daniel@brockman.se> writes:
> Consider the following code:
>
> struct fruit
> {
> enum { APPLE, MELON, ORANGE } type;
> ...
> } fruit;
>
> ...
>
> switch (fruit.type)
> {
> case APPLE:
> ...; break;
> case MELON:
> ...; break;
> case ORANGE:
> ...; break;
> }
>
> Here, as soon as another value is added to the enum, gcc will warn
> about the switch statement not handling it.
>
> But what if `fruit_type' is neither `APPLE' nor `ORANGE'?
What I really meant to say here was the following:
But what if `fruit_type' is neither `APPLE', `MELON', nor `ORANGE'?
Apologies,
--
Daniel Brockman <daniel@brockman.se>