This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53232] No warning for main() without a return statement with -std=c99
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 04 May 2012 15:38:22 +0000
- Subject: [Bug c/53232] No warning for main() without a return statement with -std=c99
- Auto-submitted: auto-generated
- References: <bug-53232-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53232
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-04 15:38:22 UTC ---
I think -Wreturn-type says in C++ it doesn't warn about declaring:
main() {}
with no return type. That only applies to C++, so isn't relevant here.
IMHO this isn't a bug because in C99 it's well-defined what happens if you fall
off the end of main, so it would annoy people to issue a warning on perfectly
valid code whenever -Wall is enabled.
But then I rarely use C99 so I don't really care. If anyone suggested warning
for C++ programs that fall off the end of main I would be upset :)
The fact people might call main() from other functions is a sort-of-convincing
argument to warn about it (calling main isn't allowed in C++).