c/7508: GCC refuses to compile a declartion right after a 'case' in switch
ddcc@email.com
ddcc@email.com
Tue Aug 6 09:36:00 GMT 2002
>Number: 7508
>Category: c
>Synopsis: GCC refuses to compile a declartion right after a 'case' in switch
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Tue Aug 06 09:36:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: ddcc@email.com
>Release: GCC 3.1.1
>Organization:
>Environment:
Seen on MinGW, but probably problem on all platforms
>Description:
GCC refuses to compile a declaration that follows immediately after a 'case' in a 'switch', even in C99 mode:
int main()
{
int x = 1;
switch (x) { case 1: int y = 7; }
return 0;
}
Says GCC: In function `main': parse error before "int".
However, if I add a dummy statement before the declaration, GCC compiles it fine:
int main()
{
int x = 1;
switch (x) { case 1: 4 + 5; int y = 7; }
return 0;
}
>How-To-Repeat:
Compile the first example in the report.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list