public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC] Deprecate "implicit int" for main() in C++
@ 2018-04-25 13:12 Jonathan Wakely
  2018-04-25 13:57 ` Andrew Haley
  0 siblings, 1 reply; 16+ messages in thread
From: Jonathan Wakely @ 2018-04-25 13:12 UTC (permalink / raw)
  To: gcc

G++ allows the 'main' function to be declared without a return type:

$ gcc-8 -x c++ - <<< 'main() { }'
<stdin>:1:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]

We enabled -Wreturn-type by default in GCC 8, so code using the
extension will get warnings even without -Wall now. Users might want
to use -Werror=return-type to ensure they aren't bitten by the new
optimizations that assume control never reaches the end of a non-void
function.

Should we deprecate the "implicit int" extension for GCC 9?

Deprecating it wouldn't mean we have to remove it any time soon, and
it could still be allowed by -fpermissive.

N.B. we also allow "implicit int" in system headers, which we might
need to continue doing because some OS headers are not C++-aware, and
users can't fix their OS headers. That isn't true for 'main' because
users control that, and can fix it, and fixing it has no downside.

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

end of thread, other threads:[~2018-05-08 12:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-25 13:12 [RFC] Deprecate "implicit int" for main() in C++ Jonathan Wakely
2018-04-25 13:57 ` Andrew Haley
2018-04-25 13:59   ` Jason Merrill
2018-04-25 14:04     ` Andrew Haley
2018-04-25 14:40       ` Jonathan Wakely
2018-04-25 15:48         ` Andrew Haley
2018-04-25 16:22           ` Jonathan Wakely
2018-04-25 16:45             ` David Malcolm
2018-04-25 17:13               ` Jonathan Wakely
2018-04-25 17:50                 ` Nathan Sidwell
2018-04-25 21:14                   ` Jonathan Wakely
2018-04-25 15:31   ` Jonathan Wakely
2018-04-25 15:54     ` Jason Merrill
2018-05-08 11:36     ` Florian Weimer
2018-05-08 11:39       ` Jonathan Wakely
2018-05-08 12:02       ` Andreas Schwab

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