On Wed, Apr 25, 2018 at 9:53 AM, Andrew Haley <a...@redhat.com> wrote:
> 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).

Indeed, so that optimization doesn't affect main, because there is no
undefined behavior.

The warning by default seems sufficient to me.

Jason

Reply via email to