Re: Operator precedence is undefined?

From: Date: Sat, 20 Jul 2013 09:34:53 +0000
Subject: Re: Operator precedence is undefined?
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
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
[email protected]


Thread (30 messages)

« previous php.internals (#68267) next »