public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/29444] New: parser bug for variable declaration immediately following case statement in switch block
@ 2006-10-12 20:29 alx at gotnull dot net
2006-10-12 20:47 ` [Bug c/29444] " pinskia at gcc dot gnu dot org
2006-10-12 22:28 ` neil at daikokuya dot co dot uk
0 siblings, 2 replies; 4+ messages in thread
From: alx at gotnull dot net @ 2006-10-12 20:29 UTC (permalink / raw)
To: gcc-bugs
The following code:
int main( int argc, char** argv )
{
switch ( 1 )
{
case 1:
int bug = 0;
break;
}
return 0;
}
is valid C syntax and should compile, but gcc gives the error:
bug.c: In function 'main':
bug.c:6: error: expected expression before 'int'
gcc doesn't properly interpret the variable declaration immediately following
the "case 1:" However, if another statement is inserted (even a blank
statement, just a semicolon) such as:
int main( int argc, char** argv )
{
switch ( 1 )
{
case 1:
; // workaround
int bug = 0;
break;
}
return 0;
}
gcc compiles this fine.
I have successfully reproduced this on multiple platforms both 32 bit and 64
bit in gcc 4.1.1 and 4.0.2. I suspect earlier and intermediate versions suffer
from this bug as well.
--
Summary: parser bug for variable declaration immediately
following case statement in switch block
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: trivial
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: alx at gotnull dot net
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29444
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/29444] parser bug for variable declaration immediately following case statement in switch block
2006-10-12 20:29 [Bug c/29444] New: parser bug for variable declaration immediately following case statement in switch block alx at gotnull dot net
@ 2006-10-12 20:47 ` pinskia at gcc dot gnu dot org
2006-10-12 22:27 ` Neil Booth
2006-10-12 22:28 ` neil at daikokuya dot co dot uk
1 sibling, 1 reply; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-10-12 20:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-10-12 20:47 -------
This is not valid C code.
even though declarations can appear intermixed with statements, they are still
not a statement and cannot be placed anywhere a statement can.
This is a dup of bug 29062.
*** This bug has been marked as a duplicate of 29062 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29444
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Bug c/29444] parser bug for variable declaration immediately following case statement in switch block
2006-10-12 20:47 ` [Bug c/29444] " pinskia at gcc dot gnu dot org
@ 2006-10-12 22:27 ` Neil Booth
0 siblings, 0 replies; 4+ messages in thread
From: Neil Booth @ 2006-10-12 22:27 UTC (permalink / raw)
To: pinskia at gcc dot gnu dot org; +Cc: gcc-bugs
pinskia at gcc dot gnu dot org wrote:-
>
>
> ------- Comment #1 from pinskia at gcc dot gnu dot org 2006-10-12 20:47 -------
> This is not valid C code.
> even though declarations can appear intermixed with statements, they are still
> not a statement and cannot be placed anywhere a statement can.
>
> This is a dup of bug 29062.
It's going to keep getting reported until the diagnostic improves and
shows that it's not the compiler that is confused.
Neil.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/29444] parser bug for variable declaration immediately following case statement in switch block
2006-10-12 20:29 [Bug c/29444] New: parser bug for variable declaration immediately following case statement in switch block alx at gotnull dot net
2006-10-12 20:47 ` [Bug c/29444] " pinskia at gcc dot gnu dot org
@ 2006-10-12 22:28 ` neil at daikokuya dot co dot uk
1 sibling, 0 replies; 4+ messages in thread
From: neil at daikokuya dot co dot uk @ 2006-10-12 22:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from neil at daikokuya dot co dot uk 2006-10-12 22:27 -------
Subject: Re: parser bug for variable declaration immediately following case
statement in switch block
pinskia at gcc dot gnu dot org wrote:-
>
>
> ------- Comment #1 from pinskia at gcc dot gnu dot org 2006-10-12 20:47 -------
> This is not valid C code.
> even though declarations can appear intermixed with statements, they are still
> not a statement and cannot be placed anywhere a statement can.
>
> This is a dup of bug 29062.
It's going to keep getting reported until the diagnostic improves and
shows that it's not the compiler that is confused.
Neil.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29444
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-10-12 22:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-12 20:29 [Bug c/29444] New: parser bug for variable declaration immediately following case statement in switch block alx at gotnull dot net
2006-10-12 20:47 ` [Bug c/29444] " pinskia at gcc dot gnu dot org
2006-10-12 22:27 ` Neil Booth
2006-10-12 22:28 ` neil at daikokuya dot co dot uk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).