Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/bin/echo



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 <uwe%stderr.spb.ru@localhost>
>     Message-ID:  <YYwasQrvKf7NgmED%pony.stderr.spb.ru@localhost>
> 
>   | > 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


Home | Main Index | Thread Index | Old Index