Keith Thompson said:
[...]
I argue that this:
int main() { /* ... */ }
is *not* equivalent to this:
int main(void) { /* ... */ }
[...]
Probably adding the wording for "int main()" to the normative text or to
the footnote 9 (I'm using N1256) seems to be necessary to clarify the
intent.
This would allow
int main(argc, argv, envp)
int argc;
char **argv;
char **envp;
{}
because the defined type is int main().
What if "It shall be defined with [...]" were changed to "It shall be
(defined as) compatible with [...]"? This, I believe, allows old-style
definitions that actually define main with 0 or 2 parameters of the
appropriate type, without allowing other old-style definitions.
Sorry, that makes it worse. function types declared or defined
old-style are _compatible_ based only on return type regardless of
their parameters. ALL of the following:
int main () { }
int main (x, y, z) double x; FILE y; _Complex z; { }
int main (q) size_t (*q) (size_t (*) ()); { }
are compatible with EITHER of:
int main (void)
int main (int, char**)
but those two aren't compatible with each other; it's not transitive.
I think it's obvious what was meant is that main must return int and
take either no parameters (specified either oldstyle or new) or two
parameters one int and one char** (ditto). The type system differs
oldstyle vs newstyle for hysterical raisins, making this clumsy.
What we want is a notion of 'effectively same function type' that
isn't directly defined elsewhere in the Standard, although 6.5.2.2p6-9
covers most of the ground (except varargs, which don't apply here).
We probably could say something like 'main must be defined such that
it can be called as one of int(*)(void) or int(*)(int,char**)
correctly per 6.5.2.2 possibly excluding the special dispensation for
unsigned=signed int' but IMO that's _less_ helpful.
The Standard needs to care about making the initial call work, since
that's critical to every (hosted) program. The _declared_ type of main
differs for oldstyle vs newstyle, but matters only for recursive calls
which are pretty useless outside IOCCC. <OT> C++ prohibits them. </>
That said, I don't believe anyone competent to be an implementor has
ever misunderstood this rather simple and basic provision, and it
would be a mistake for the committee members who already don't have
overmuch time for actual problems to waste their time on this.
Fortunately(?) many if not all here apparently have time to waste.
Smiley omitted, after (unhappy) reconsideration. This is the sort of
thing that might actually lead me to join the grumpiness campaign, if
it still exists and hasn't been taken over by the int64 campaign. <G>