[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Evaluation order, assignment order
- From: Dave Dodge <dododge@...>
- Date: Thu, 22 Jun 2006 08:59:25 -0400
On Thu, Jun 22, 2006 at 10:07:51AM -0300, Roberto Ierusalimschy wrote:
> The point is that you cannot evaluate two arguments "in parallel".
> Harbison & Steele[1] say something similar for ANSI C, but I could not
> find this in the standard. Lua should also respect that restriction.
6.5.2.2 [#10] The order of evaluation of the function designator,
the actual arguments, and subexpressions within the actual arguments
is unspecified, but there is a sequence point before the actual
call.
So any side effects from evaluating the arguments will occur in some
unspecified order. Since there's no implicit sequence points between
the arguments, if the argument expressions don't contain any sequence
points of their own and they try to modify the same object more than
once, you end up with undefined behavior:
6.5 [#2] Between the previous and next sequence point an object
shall have its stored value modified at most once by the evaluation
of an expression. Furthermore, the prior value shall be accessed
only to determine the value to be stored.
-Dave Dodge