This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Missing default in switch
On Wed, 20 Oct 1999 19:45:14 GMT, "T.E.Dickey"
<dickey@shell.clark.net> wrote:
>In comp.std.c David R Tribble <david@tribble.com> wrote:
>
>> Some compilers (and some lint programs) allow you to add a special
>> comment where the missing default goes to indicate that the default
>> case is omitted on purpose.
>
>otoh, if you _do_ supply a 'default:', then some compilers will generate
>more compact code
How? Adding an empty default doesn't change the meaning of the switch
statement.
MSVC supports
switch (foo) {
...
default:
__assume(0); /* unreachable */
}
which asserts that the default case will never occur, removing the
need to check for it. Is this the sort of thing you're thinking of?
-- Mat.