Lately I've had to use Microsoft's Visual C++, and I just
noticed this. In the following switch statement:
switch( someint )
{
case 0:
break;
case 1:
break;
default:
}
MSVC6 gives an error "syntax error : missing ';' before '}'".
It does not like the last label, be it default: or not, with
no C statement under it.
According to the Standard, every label must be followed by a
statement, even if that's just the empty statement ';'.
Testing this on gcc 2.95, it compiles without any warnings and the
-Wall option specified.
If you specify -ansi -pedantic, gcc 2.95 (and earlier versions) will
complain, too.
Which makes me wonder what does the standard say on this. Are
"empty last labels" prohibited?
Yes.
--
"Debian for hackers, Red Hat for suits, Slackware for loons."
--CmdrTaco <URL:http://slashdot.org/articles/99/03/22/0928207.shtml>
--