Hi all,

Explanation for undefined behaviors.

=======================
// If a side effect on a variable is unsequenced relative to another
// side effect on the same variable, the behavior is undefined.
$i = 1;
$i = ++$i + $i++;  // undefined behavior
$i = $i++ + 1;       // undefined behavior (but $i = ++$i + 1; is
well-defined)
f(++$i, ++$i);       // undefined behavior
f($i = -1, $i = -1); // undefined behavior

// If a side effect on a varible is unsequenced relative to a value
// computation using the value of the same variable, the behavior
// is undefined.
$a[$i] = $i++; // undefined behavior
=======================

If there are more of these, please point it out.

The cause of confusion is the fact that these are not about precedence.
It would better to have dedicated section for undefined behaviors, IHMO.

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

Reply via email to