Bug in C FE or difference between C & C++
Richard Guenther
richard.guenther@gmail.com
Wed Jun 2 10:29:00 GMT 2010
On Wed, Jun 2, 2010 at 12:00 PM, Bingfeng Mei <bmei@broadcom.com> wrote:
> Hi,
>
> For the following simple example,
>
> int main(void)
> {
> int a=0;
> switch (a)
> {
> case 0:
> int b=2;
> break;
> }
> }
>
> GCC will complain:
> tst.c: In function 'main':
> tst.c:7:6: error: a label can only be part of a statement and a declaration is not a statement
> G++ will compile silently.
>
> Is this a C FE bug or due to difference between C & C++?
You need a block around the variable declaration. The error
isn't very helpful here.
Richard.
>
> Thanks,
> Bingfeng
>
>
More information about the Gcc
mailing list