More Re: Function Argument Evaluation argument

Jonathan Gingerich jon at maui.cs.ucla.edu
Sat Apr 6 04:29:45 AEST 1991


In article <18272 at crdgw1.crd.ge.com> volpe at camelback.crd.ge.com (Christopher R Volpe) writes:
>|>
>|>    printf("%d %d\n", (1, v), (1, v++));
>|>                      ^^^^^^  ^^^^^^^^
>This is all subject to the comment Doug made about the possibility
>of the "unspecified order of subexpressions" overriding the
>"specified order and sequence point locations" of the comma operator.
>A formal interpretation would be needed on this, it seems, but I
>would suspect that the Committee would rule that the semantics of
>the comma operator hold, even when used as an argument to a function.
>But that's just my guess. If the semantics of the comma operator
>are maintained, then the evaluations of "v" and "v++" are always
>separated by a sequence point, regarless of the order of evaluation of
>exp1 and exp2. 

Where are the sequence points on the comma operator?  I would guess there
is only one between the first and second expression in which case the
evaluation order 1 - 1 - (sequence point) - (sequence point) - v - v++
would make the result undefined.  The output of:

	printf("%d %d\n", f(...v...), f(...v++...)) 

is unspecified and not undefined because the sequence point before f(), but
since the subexpressions ...v... and ...v++... cannot be interleaved (unless
this is a case of the ambiguity Doug was talking about), it is not as
interesting.

Jon.



More information about the Comp.std.c mailing list