From: henson dot garth at gmail dot com Operating system: Linux PHP version: 5.2.1 PHP Bug Type: Math related Bug description: Increment/Decrement operator calculation oddity
Description: ------------ The increment/decrement operators seem to calculate out of order compared to other languages and even previous versions of PHP. I compared this report numerous times against a 4.3.11 install that I am running to verify the inconsistency. In the case of PHP 5.2.x, the increment operator seems to be processed in an inappropriate order to the rest of the statement. In 4.3.11, everything is presented just as expected (as my Expected results display below). Reproduce code: --------------- $a = array(); // Begin Test 1 $b = 0; $a[$b++] = $b; var_dump($a); $a = array(); // Begin Test 2 $b = 0; $a[$b] = $b++; var_dump($a); $a = array(); // Begin Test 3 $b = 10; $a[$b--] = $b; var_dump($a); $a = array(); // Begin Test 4 $b = 10; $a[$b] = $b--; var_dump($a); Expected result: ---------------- array(1){[0] => int(1)} array(1){[0] => int(0)} array(1){[10] => int(9)} array(1){[10] => int(10)} Actual result: -------------- array(1){[0] => int(1)} array(1){[1] => int(0)} array(1){[10] => int(9)} array(1){[9] => int(10)} -- Edit bug report at http://bugs.php.net/?id=40755&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40755&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40755&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40755&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40755&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40755&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40755&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40755&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40755&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40755&r=support Expected behavior: http://bugs.php.net/fix.php?id=40755&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40755&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40755&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40755&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40755&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40755&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40755&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40755&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40755&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40755&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40755&r=mysqlcfg