#41470 [Opn->Bgs]: referance assignment will cause unexpected side effect

From: Date: Thu, 24 May 2007 05:57:08 +0000
Subject: #41470 [Opn->Bgs]: referance assignment will cause unexpected side effect
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112975@lists.php.net to get a copy of this message
ID: 41470 Updated by: johannes@php.net Reported By: xiezhenye at gmail dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: any PHP Version: 5.2.2 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 http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You shouldn't use multiple [in|de]crement operations on the same opeartion. The result of that is undefined. Previous Comments: ------------------------------------------------------------------------ [2007-05-23 09:19:02] xiezhenye at gmail dot com Description: ------------ after a referance assignment, the result of the expression will be an un expected value. Reproduce code: --------------- <?php $a = 1; $c = ++$a+$a++; echo $c; echo "\n"; $a = 1; $b = &$a; $c = ++$a+$a++; echo $c; ?> Expected result: ---------------- 4 4 Actual result: -------------- 4 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41470&edit=1

« previous php.bugs (#112975) next »