This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: strange warning with gcc 3.x
- From: Joe Buck <jbuck at synopsys dot com>
- To: Gunther Nikl <gni at gecko dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 20 Aug 2003 09:03:53 -0700
- Subject: Re: strange warning with gcc 3.x
- References: <20030820153208.GA92981@lorien.int.gecko.de>
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.