All that you say is fine and I'd agree if void main(void) was
"implementation defined behavior".
The reason I disagreed with Kenny and perhaps with you is that I think
void main(void) is UB in C99. (I don't know about C90, I don't have
that standard)
Here's why
5.1.2.2.1 Program startup p 1
[I've fixed the "fi" ligature above.]
Emphasis added by me.
Then, 4. Conformance p 1
What this undoubtedly means is that the program is required to be
defined with a return type of int.
If not, it's UB. Do we agree on this interprentation?
Um, no. I agree that C99 5.1.2.2.1p1 could be reasonably read that
way, and the wording should probably be cleaned up a bit, but I'm
almost certain that the *intent* is that main shall be defined:
as int main(void)
*OR*
as int main(int argc, char *argv[])
*OR*
in some other implementation-defined manner. I don't believe the
phrase "with a return type of int" was intended to cover the "some
other implementation-defined manner" case.
I note that the interpretation that it does calls for a somewhat
strained interpretation of the wording. The phrase "or in some other
implementation-defined manner" clearly (at least it's clear to me)
logically follows "It shall be defined". Compare my interpretation:
It shall be defined ... in some other implementation-defined
manner.
to yours:
It shall be defined with a return type of int ... in some other
implementation-defined manner.
As a matter of common sense (yes, I know that's a dangerous thing to
apply to the standard), I can't think of any good *reason* why an
implementation should be allowed to vary the parameters but not the
return type.
The problem with the current wording is that the phrase "with a return
type of int" appears only once, but is meant to apply to two of the
following three clauses. I think that's just a consequence of the
fact that C90 just has the first two clauses, and the third was tacked
on in C99.
But even if we accept your interpretation, that 5.1.2.2.1 doesn't
permit void main(void), 4p6 does (which is why I've long said that the
added permission in 5.1.2.2.1 is redundant):
A conforming implementation may have extensions (including
additional library functions), provided they do not alter the
behavior of any strictly conforming program.
and 4p8:
An implementation shall be accompanied by a document that defines
all implementation-defined and locale-specific characteristics and
all extensions.
Ignoring the added phrase in 5.1.2.2.1, "void main(void)" is a valid
extension. As such, an implementation that supports it is required to
document it. The documentation requirement is meaningless if an
implementation is allowed to lie in its own documentation.
In the absence of such documentation, the behavior of void main(void)
is undefined. And if an implementation does support void main(void),
it needn't behave in the obvious manner. A conforming implementation
could, as a documented extension, say that this program:
void main(void) { }
prints "main returns int, you fool!" on stderr.
If we do, can you claim the same you claimed about implementation
documentation for undefined behavior?
If you agree with me about void main(void), I think you can also agree
that the standard doesn't require an implementation to document UB. If
the implementation chooses so, it's outside of the scope of the C
stardard; whether the documentation lies or not is not C's concern.
If an implementation defines behavior that is not defined by the
standard in the document required by C99 4p8, then it must do so
accurately.