#34795 [Opn->Fbk]: Passing assignment result by reference
| From: | sniper@php.net | Date: | Sun, 09 Oct 2005 19:11:34 +0000 |
| Subject: | #34795 [Opn->Fbk]: Passing assignment result by reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-86288@lists.php.net to get a copy of this message | ||
ID: 34795
Updated by: sniper@php.net
Reported By: tomas_matousek at hotmail dot com
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: WinXP
PHP Version: 5.1.0RC1
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-10-09 20:58:39] tomas_matousek at hotmail dot com
Description:
------------
Let's have a function with a parameter passsed by reference.
function f(&$x) { }
Now, call this function as follows:
f($a = $b = $c);
This will sometimes fail sometimes not depending on whether any of the
variables $a, $b, $c has previously been used with =& operator. In a
such case, the call succeeds with $a being aliased to $x. Otherwise,
fatal error occures: "Only variables can be passed by reference".
this code works:
$b =& $z;
f($a = $b = $c);
this code doesn't:
f($a = $b = $c);
So the "correctness" of the code depends on whether there exists an
alias of one of the variable. That's weird, isn't it?
Reproduce code:
---------------
$b =& $z;
f($a = $b = $c);
f($u = $v = $w);
Expected result:
----------------
OK.
OK.
- or -
Error.
Error.
Actual result:
--------------
OK.
Error.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34795&edit=1