Skarmander <> writes:
[...]
> GCC with -std=c99 will not issue a warning, because in C99 it's legal
> to omit the return statement from main() (and *only* main()), in which
> case a return value of 0 is implied.
>
> I don't think I've yet read why this was considered a good idea; maybe
> to retroactively fix all the broken code that invoked undefined
> behavior.
Omitting the return statement in main() never invoked undefined
behavior (unless a recursive call to main() attempts to use the
result). At worst, it merely returns an unspecified status to the
calling environment, and the behavior of the calling environment is
outside the scope of the C standard.
I think part of the motivation for the change is that made some of the
examples in K&R retroactively valid.
The Rationale (C99RationaleV5.10.pdf) doesn't mention this change as
far as I can tell.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.