#41373 [Opn->Bgs]: Incorrect expression evaluation with pre-increment
| From: | derick@php.net | Date: | Sun, 13 May 2007 18:18:12 +0000 |
| Subject: | #41373 [Opn->Bgs]: Incorrect expression evaluation with pre-increment | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-112607@lists.php.net to get a copy of this message | ||
ID: 41373
Updated by: derick@php.net
Reported By: romy4 at online dot ua
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: WinNT,Linux
PHP Version: 5.2.2
New Comment:
.
Previous Comments:
------------------------------------------------------------------------
[2007-05-13 15:00:01] carsten_sttgt at gmx dot de
> $i=++$i + ++$i;
There is one important rule: Don't change the value of a variable more
then one times between sequence points.
For a better explanation you can start for example here [1]. It's the
same reason as in bug #41364.
BTW:
Already with "$i = $i++;" you have different results with different
compilers (the way the code optimizer work).
Regards,
Carsten
[1] http://c-faq.com/expr/seqpoints.html
------------------------------------------------------------------------
[2007-05-12 13:50:44] romy4 at online dot ua
i do not know how is php engine works inside but logically
++i should increment 'i' value by reference not copy of 'i' variable.
------------------------------------------------------------------------
[2007-05-12 13:45:34] romy4 at online dot ua
sorry, check what? i thought '++' has higher priority than '+' that
shown in the manual
(http://www.php.net/manual/ru/language.operators.php) or not at last
time?
------------------------------------------------------------------------
[2007-05-12 09:38:50] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The evaluation order of this construct is undefined and random things
may happen.
------------------------------------------------------------------------
[2007-05-12 08:41:56] itonix at inet dot ua
Very! VERY important bug
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/41373
--
Edit this bug report at http://bugs.php.net/?id=41373&edit=1