public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bmcfadden at cdp dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/31977] New: can return OK from "int main()" without a return statement by using a goto before the return Date: Thu, 17 May 2007 15:46:00 -0000 [thread overview] Message-ID: <bug-31977-14564@http.gcc.gnu.org/bugzilla/> (raw) I'm using gcc 3.4.5, and I was looking into a weird condition. The following program compiles OK: #include <stdio.h> int alloc() { return 0; } int main(int argc, char* argv[]) { printf("Testing!\n"); if(alloc() == 0)goto Radhe; return 0; Radhe: printf("Hello\n"); } The result is a program which prints "Testing", then "Hello", and then exits. I and a few other people expect that the compiler would generate an error during compile, because main should return an int, and not all code paths have a return statement; however, both gcc and msvc are compiling this OK. added note: this bug was recently discussed on the NTDEV mailing list. -- Summary: can return OK from "int main()" without a return statement by using a goto before the return Product: gcc Version: 3.4.5 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bmcfadden at cdp dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31977
next reply other threads:[~2007-05-17 15:46 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-05-17 15:46 bmcfadden at cdp dot com [this message] 2007-05-17 15:48 ` [Bug c/31977] " bmcfadden at cdp dot com 2007-05-17 15:52 ` bmcfadden at cdp dot com 2007-05-17 15:54 ` bmcfadden at cdp dot com 2007-05-17 17:53 ` pinskia at gcc dot gnu dot org 2007-05-17 19:39 ` bangerth at dealii dot org 2007-05-17 19:45 ` pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-31977-14564@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).