-Wswitch-enum and -Wswitch-default

Manuel López-Ibáñez lopezibanez@gmail.com
Sat Mar 31 22:02:00 GMT 2007


On 30/03/07, Ching, Jimen  (US SSA) <jimen.ching@baesystems.com> wrote:
> Hi,
>
> I'm using g++ 4.1.1 under Fedora Core 5 in an X86 system.
>
> I read the GCC manual and it says -Wall includes the -Wswitch-enum
> and -Wswitch-default warnings.  But I had to supply these command
> line options explicitly before the warnings are generated.  Is the
> manual wrong or is there a bug in g++?
>
> Thanks in advance for any help.
>

Does it really say that? Can you quote the paragraph? The manual for
GCC 4.1.1 available at
http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Warning-Options.html#Warning-Options
says:

-Wswitch
    Warn whenever a switch statement has an index of enumerated type
and lacks a case for one or more of the named codes of that
enumeration. (The presence of a default label prevents this warning.)
case labels outside the enumeration range also provoke warnings when
this option is used. This warning is enabled by -Wall.

-Wswitch-default
    Warn whenever a switch statement does not have a default case.

-Wswitch-enum
    Warn whenever a switch statement has an index of enumerated type
and lacks a case for one or more of the named codes of that
enumeration. case labels outside the enumeration range also provoke
warnings when this option is used.

Therefore, only -Wswitch is enabled by -Wall but neither of
Wswitch-default or Wswitch-enum are.

Cheers,

Manuel.



More information about the Gcc mailing list