public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37231]  New: GCC does not compile code with label statements that are followed by a declaration
@ 2008-08-25  9:51 colding at 42tools dot com
  2008-08-25 10:44 ` [Bug c/37231] " paolo dot carlini at oracle dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: colding at 42tools dot com @ 2008-08-25  9:51 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-05-09 23:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-25  9:51 [Bug c/37231] New: GCC does not compile code with label statements that are followed by a declaration colding at 42tools dot com
2008-08-25 10:44 ` [Bug c/37231] " paolo dot carlini at oracle dot com
2008-08-25 18:56 ` manu at gcc dot gnu dot org
2009-07-08 19:36 ` aapo dot rantalainen at gmail dot com
2009-07-08 19:43 ` pinskia at gcc dot gnu dot org
2009-07-08 21:34 ` manu at gcc dot gnu dot org
2009-07-09  9:25 ` manu at gcc dot gnu dot org
2010-05-09 10:30 ` alex dot pyattaev at gmail dot com
2010-05-09 15:27 ` manu at gcc dot gnu dot org
2010-05-09 19:07 ` alex dot pyattaev at gmail dot com
2010-05-09 23:25 ` dougsemler at gmail dot com
2010-05-09 23:29 ` alex dot pyattaev at gmail dot com

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).