Source-Changes-D archive

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

Re: CVS commit: src/bin/echo



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

If the standards people wanted to make that change, they should have
done it properly, and made it be void main() instead of int main().
That would have meant changing the universe, but at least it would have
provided an opportunity to examine code that might have been broken
by this change.

That also perhaps indicates why things weren't breaking (why no warning
was being issued from gcc/clang about the code that was in echo).
New versions of the compiler probably have been taught that main is
special, and it isn't necessary to return a value, even though it is
a function which is supposed to return one.    Sad indeed.
The compile I did with -Wall that produced the error was with a
slightly older compiler version than is used in HEAD.

kre



Home | Main Index | Thread Index | Old Index