This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Deprecate "implicit int" for main() in C++
- From: Andrew Haley <aph at redhat dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Wed, 25 Apr 2018 14:53:01 +0100
- Subject: Re: [RFC] Deprecate "implicit int" for main() in C++
- References: <20180425122305.GS20930@redhat.com>
On 04/25/2018 01:23 PM, Jonathan Wakely wrote:
> 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.
But ISO C++ allows control to reach the end of main(), and
automagically returns 0. I guess you didn't mean that, but your reply
was confusing.
N4659, Section 6.6.1 Para 5:
If control flows off the end of the compound-statement of main, the
effect is equivalent to a return with operand 0 (see also 18.3).
--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671