#31512 [Opn->Bgs]: wrong expression execution order
| From: | derick@php.net | Date: | Wed, 12 Jan 2005 12:29:34 +0000 |
| Subject: | #31512 [Opn->Bgs]: wrong expression execution order | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-71950@lists.php.net to get a copy of this message | ||
ID: 31512
Updated by: derick@php.net
Reported By: dan at yes dot lt
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: any
PHP Version: 4.3.10
New Comment:
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2005-01-12 13:19:47] dan at yes dot lt
<?php
$a = 10;
$b = &$a;
$a = 10;
$c = $a++ + ++$a;
echo "$c\n\n"; // 22
$a = 10;
$c = ++$a + $a++;
echo "$c\n\n"; // 23 ??
?>
it works if there is no $b =&$a reference, and fails, if there is that
reference...
------------------------------------------------------------------------
[2005-01-12 13:01:21] tony2001@php.net
Submitted twice.
------------------------------------------------------------------------
[2005-01-12 11:57:44] dan at yes dot lt
Description:
------------
Arithmetic expression execution returns unexpected results with ++ or
-- operators.
Reproduce code:
---------------
$a = 10;
$c = $a++ + ++$a;
echo "$c\n";
$a = 10;
$c = ++$a + $a++;
echo "$c\n";
Expected result:
----------------
22
22
Actual result:
--------------
22
23 <- ?? Why ??
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31512&edit=1