More Re: Function Argument Evaluation argument
Paul Eggert
eggert at twinsun.com
Sat Apr 6 12:22:20 AEST 1991
In commenting on
printf("%d %d\n", (1, v), (1,v++));
volpe at camelback.crd.ge.com (Christopher R Volpe) writes:
No matter what the order of evaluation of the function
arguments is, there's always a sequence point separating the
references to v.
While the ANSI standard does not clearly address this point, Jim Brodie
has reported [Journal of C Language Translation 2, 3 (Dec. 1990), 207-215]
that the general opinion of X3J11 seems to be that the sequence point
in an expression X=F(Y) prior to the call to F causes only a partial
ordering on the subexpressions F and Y; it does not control the
ordering of other subexpressions like X. From this, I would expect
that the sequence point between A and B in the comma expression (A,B)
establishes only a partial order on A and B, and does not place
constraints on the ordering of expressions outside (A,B). Therefore,
printf("%d %d\n", (1, v), (1,v++));
isn't conforming, because an implementation can evaluate the two `1's
first, and then evaluate `v' and `v++' in parallel, so to speak.
More information about the Comp.std.c
mailing list