From:             nisoi at mail dot ru
Operating system: Linux 2.6.15 / GENTOO
PHP version:      5.1.4
PHP Bug Type:     Scripting Engine problem
Bug description:  Operator precedence problem

Description:
------------
Looks like there is the operator precedence problem in 5.1.4 (5.1.2 too).
4.4.2 works fine.

When you try to compare the variable with the result of an assigning a
value to it, both left and right parts are equal.
But when you force the left part to evaluate in some way that does not
change the value, left and right parts become different.


Reproduce code:
---------------
$i = 1;
echo ( ( ($i) == ($i = $i + 1)) ? "BUG - THEY ARE EQUAL" : "OK")."\n";
echo ( ( ($i + 0) == ($i = $i + 1)) ? "BUG - THEY ARE EQUAL" :
"FIX")."\n";


Expected result:
----------------
OK
FIX


Actual result:
--------------
BUG
FIX


-- 
Edit bug report at http://bugs.php.net/?id=37995&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37995&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=37995&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37995&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37995&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37995&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37995&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37995&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37995&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37995&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37995&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37995&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37995&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37995&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37995&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37995&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37995&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37995&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37995&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37995&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37995&r=mysqlcfg

Reply via email to