lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] sequence input editor -- how to get accepted keywords


From: Vaclav Slavik
Subject: Re: [lmi] sequence input editor -- how to get accepted keywords
Date: Sat, 26 Jun 2010 20:41:29 +0200

On Sat, 2010-06-26 at 17:29 +0000, Greg Chicares wrote:
> Adding 'default:' prevents '-Wswitch' from warning about that,
> but wouldn't '-Wswitch-enum' be suitable? 

I have trouble imagining any situation when this -- or -Wswitch-default
for that matter -- would be a good idea. The whole point of using
'default:' is to express "all other values should be handled the same".
Likewise, the whole point of not including it is to express "there's no
default, this switch should special-case all possibilities". Per the
documentation, -Wswitch helps with exactly that: it warns about missing
labels, unless there's an all-catching 'default:' label.

What is the problem with gcc 3.4.5 exactly? That it interprets -Wswitch
differently from what
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html says, namely that

        -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 (even if there is a default label).
                This warning is enabled by -Wall.

?
As far as I can tell, -Wall shouldn't cause any warning if there's a
'default:' label, should it?

Regards,
Vaclav




reply via email to

[Prev in Thread] Current Thread [Next in Thread]