Nicholas Clark writes:
> Also, I'm never totally confident on what isn't quite undefined behaviour in
> C, but something like
>   $a = $b + ++$b;
> doesn't appear to have multiple side effects, yet it ought to be undefined.

It is undefined in C.  The standard says that between any adjacent pair
of sequence points,

  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.

C<b + ++b> modifies b once, reads it once to determine the value to be
stored (C<++b), and also reads it one further time (to determine the
result of the addition), so it's undefined.

Aaron Crane

Reply via email to