Ask a Question related to PHP Bugs, Design and Development.
-
henson dot garth at gmail dot com #1
#40755 [NEW]: Increment/Decrement operator calculation oddity
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 [url]http://bugs.php.net/?id=40755&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40755&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40755&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40755&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40755&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40755&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40755&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40755&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40755&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40755&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40755&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40755&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40755&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40755&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40755&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40755&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40755&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40755&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40755&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40755&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40755&r=mysqlcfg[/url]
henson dot garth at gmail dot com Guest
-
#39609 [NEW]: increment/decrement inconsistency
From: arpad@php.net Operating system: PHP version: 5.2.0 PHP Bug Type: Scripting Engine problem Bug description: ... -
Date oddity in Acrobat, default page size oddity
Got two things driving me nuts. One, when I go to Save As a file, the file dats come up in the form like this: Saturday, July -2147483642, 41221,... -
Calculation based on calculation
I'm new to Acrobat 5.05 and Javascript... I have a simple issue/question: There are 3 columns, QUANTITY, EACHES COST, LINE TOTAL As the... -
#25674 [Opn->Bgs]: increment/decrement inconsistency and error
ID: 25674 Updated by: sniper@php.net Reported By: lew at mailduct dot com -Status: Open +Status: ... -
#25674 [NEW]: increment/decrement inconsistency and error
From: lew at mailduct dot com Operating system: FreeBSD 4.8-REL PHP version: 4.3.3 PHP Bug Type: Math related Bug... -
derick@php.net #2
#40755 [Opn->Bgs]: Increment/Decrement operator calculation oddity
ID: 40755
Updated by: [email]derick@php.net[/email]
Reported By: henson dot garth at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: Linux
PHP Version: 5.2.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
[url]http://www.php.net/manual/[/url] and the instructions on how to report
a bug at [url]http://bugs.php.net/how-to-report.php[/url]
Using and modifying the same variable when using post/pre-
decrement/increment is undefined (and not only in PHP).
Previous Comments:
------------------------------------------------------------------------
[2007-03-08 01:43:13] henson dot garth at gmail dot com
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 this bug report at [url]http://bugs.php.net/?id=40755&edit=1[/url]
derick@php.net Guest



Reply With Quote

