strange warning with gcc 3.x

Joe Buck jbuck@synopsys.com
Wed Aug 20 17:44:00 GMT 2003


On Wed, Aug 20, 2003 at 05:32:08PM +0200, Gunther Nikl wrote:
> Hello!
> 
> The following code generates a warning:
> 
> --cut--
> int i;
> void foo(void) {
>   switch(i) {
>     default:
>   }
> }
> --cut--
> 
> Compiling this code with: gcc -c foo.c gives:
> 
> foo.c: In function 'foo':
> foo.c:7: warning: deprecated use of label at end of compound statement
> 
> Is the warning correct?

Yes, you've written invalid C (so it would even be correct to give you
a hard error).  A label has to refer to a statement.  An empty statement
is legal:

    default:
	;

as is a break statement.  If you use an empty statement, a comment like
/* do nothing */ can make the code easier to understand.



More information about the Gcc mailing list