This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37231] New: GCC does not compile code with label statements that are followed by a declaration
- From: "colding at 42tools dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Aug 2008 09:49:48 -0000
- Subject: [Bug c/37231] New: GCC does not compile code with label statements that are followed by a declaration
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hi,
The following simple code does not build using GCC 3.3 or 4.x:
###### main.c ########
int
main(int argc, char *argv[])
{
goto out;
out:
int retv = 0;
return retv;
}
#######################
GCC tells me:
####### GCC output ########
main.c: In function ?main?:
main.c:7: error: syntax error before ?int?
main.c:8: error: ?retv? undeclared (first use in this function)
main.c:8: error: (Each undeclared identifier is reported only once
main.c:8: error: for each function it appears in.)
###########################
I'm not aware that the above code should be invalid so I think this is a
compiler bug. Putting a ';' after the label will make the code compile just
fine:
###### working main.c ########
int
main(int argc, char *argv[])
{
goto out;
out: ;
int retv = 0;
return retv;
}
##############################
Best regards,
jules
--
Summary: GCC does not compile code with label statements that are
followed by a declaration
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: colding at 42tools dot com
GCC host triplet: i686-apple-darwin9
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37231