[Scummvm-devel] Re: [Scummvm-cvs-logs] SF.net SVN: scummvm: [20970] scummvm/trunk/engines/kyra/sound_adlib.cpp
Marcus Comstedt
marcus at mc.pp.se
Tue Feb 28 07:40:28 CET 2006
"Max Horn" <max at quendi.de> writes:
> While problems should only occur when the comma operator is involved
> (including function calls, where the stack order of the target
> system can and does influence the evaluation order),
The comma operator is _not_ involved in function calls, which is why
the evaluation order is undefined. In the comma expression A,B A is
always evaluated before B (the comma operator is a sequence point).
But as I said, the comma in function calls is not a comma operator, so
the evaluation order is undefined. Of course, you can _use_ the comma
operator in a function call if you like, so in
A(B, (C,D), E)
C is evaluated before D, but A, B and E may be evaluated in any order
with repect to each other and to C and D.
Also note that it is _illegal_ to set the value of an object
(including objects of type va_list...) more than once without a
sequence point in between. See ยง6.5:2 in the C standard.
Other operators that introduce a sequence points are ||, && and ?:.
Function calls also introduce a sequence point, but only _after_ the
call address and all the arguments have been evaluated.
I don't have a C++ standard handy, but I assume it follows the same
rules as C here.
// Marcus
More information about the Scummvm-devel
mailing list