This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/7508: GCC refuses to compile a declartion right after a 'case' in switch
- From: ddcc at email dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 6 Aug 2002 16:33:56 -0000
- Subject: c/7508: GCC refuses to compile a declartion right after a 'case' in switch
- Reply-to: ddcc at email dot com
>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: