This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/70958] Flag -Wreturn-type does not warn about lacking return statement in main


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]