This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/70958] Flag -Wreturn-type does not warn about lacking return statement in main
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 04 May 2016 22:27:02 +0000
- Subject: [Bug c/70958] Flag -Wreturn-type does not warn about lacking return statement in main
- Auto-submitted: auto-generated
- References: <bug-70958-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70958
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |msebor at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The reason GCC 4.8 issues the warning is because it targets C89 by default, and
C89 doesn't say that falling off the end of main is allowed. The reason why
GCC 5.3 doesn't issue the same warning is because it targets C11 by default,
and C11 says that main that ends without explicitly returning a value as good
as one that did. You can revert to the prior behavior with 5.3 by using the
-std=c89 option.
While I believe GCC behaves correctly, I think the manual could stand to be
clarified to explain this subtle nuance (similarly to how it explains it for
C++).