This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strange warning with gcc 3.x


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]