On Thu, Nov 11, 2021 at 05:03:41 +0700, Robert Elz wrote:

>     Date:        Wed, 10 Nov 2021 22:17:05 +0300
>     From:        Valery Ushakov <u...@stderr.spb.ru>
>     Message-ID:  <yywasqrvkf7ng...@pony.stderr.spb.ru>
> 
>   | > in the sense that simply falling out of main() is exit(0)?
>   |
>   | Surprisingly - yes.
> 
> That's appalling, but perhaps not surprising.
> 
> It breaks code which believed what was promised, and did return n
> (n != 0) instead of exit(n).

The main can still return an int explicitly.

  If the return type of the main function is a type compatible with
  int, a return from the initial call to the main function is
  equivalent to calling the exit function with the value returned by
  the main function as its argument;

It's specifically the sloppy

    int main() {}

without explicit return that gets a dispensation.

-uwe

Reply via email to