Must main return a value?

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Sun Jun 30 14:44:34 AEST 1991


In article <16587 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
> Given that anonymous return in general produces an unspecified value,
> anonymous return from main() naturally would do the same.

Hold on. You're saying something about the real world here, and the real
world doesn't distinguish between ``implementation-defined'' and
``undefined'' until a standard comes along and forces the issue. ANSI
could easily have left these decisions up to the implementation, and you
haven't given any excuse for the undefined behavior that wouldn't apply
equally well to implementation-defined behavior.

Or are you claiming that ANSI never forced implementations to define
behaviors where the behavior in general produced unspecified effects? I
think not. If that were so, ``implementation-defined'' wouldn't even be
in the standard. Everything would be ``undefined.''

> While you can argue that you would like to add some more default rules
> such as automatic 0 values for anonymous returns,

Yikes, why would I argue for something like that? I was just giving an
example of what an implementation could do to define the value. Nobody
in his right mind would standardize such a rule when it breaks so many
existing implementations for no good reason.

---Dan



More information about the Comp.std.c mailing list