This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Parsing of switch statement
- To: egcs at cygnus dot com
- Subject: Re: Parsing of switch statement
- From: Joe Buck <jbuck at synopsys dot com>
- Date: Wed, 10 Dec 97 15:44:01 PST
- Reply-To: egcs at cygnus dot com
> Recently I have encountered some code that contains an empty case
> statement at the end of a switch (see example below).
Such code is neither legal C nor legal C++. I think it's an extension
to gcc; you shouldn't assume that all GNU C extensions will be available
in g++ (some clash with other C++ syntax, not sure about this one).
>
> Here is the simple test
>
> #include <stdio.h>
>
> int main (int argc, char *argv[])
> {
> int i=1;
> switch (i) {
> case 1 : printf ("1 ");
> case 0 : /* a ';' is needed here to compile with g++ */
> }
> printf ("\n");
> return 0;
> }
The ';' is needed with any C or C++ compiler other than gcc.