S
Seebs
<http://cm.bell-labs.com/cm/cs/who/dmr/cman.pdf> is the C Reference
Manual that came out with 6th Edition Unix in May 1975. In section 7,
it says:
Otherwise the order of evaluation of expressions is undefined. In
particular the compiler considers itself free to compute
subexpressions in the order it believes most efficient, even if
the subexpressions involve side effects.
This further undermines Spinny's theory. Consider that the C implementation
in V6 UNIX was probably not defined in any way by concern about what other
compiler vendors had done. Rather, it was solely defined in terms of the
observed needs and the opportunities for optimization available to them at
the time.
Which is to say: It was never the result of the alleged "careless mistake",
but was a considered decision.
This makes it possible for someone who feels it's wrong to disagree with the
priorities set by the designers, but ludicrous to claim that it was an
accident, oversight, or done in response to mysterious "vendors".
(I wish I now remembered who it was that I argued with some years back
about this very issue, I think it was in the mid-90s, but it might
have been the lateish 90s. He was firmly convinced that C should have
specified order of evaluation.)
The expressions In parentheses are evaluated (in an unspecified
order) to rvalues and assigned to the function's parameters.
My guess would be that this was a specific instance of the same general
rule.
<http://www.masswerk.at/algol60/modified_report.htm>, the Modified
Report on the Algorithmic Language Algol 60, says:
The order of evaluation of primaries within an expression is not
defined. If different orders of evaluation would produce different
results, due to the action of side effects of function
designators, then the program is undefined.
Now, the question is: Does "undefined" mean the same thing here that it
would in C (as in, "undefined behavior" being a pure wildcard), or does it
merely mean that they don't commit to which order of evaluation would have
been used?
-s