#35163 [Csd->Asn]: Array elements can lose references.

From: Date: Fri, 01 Sep 2006 04:39:08 +0000
Subject: #35163 [Csd->Asn]: Array elements can lose references.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-101602@lists.php.net to get a copy of this message
ID: 35163 Updated by: dmitry@php.net Reported By: averagomez at hotmail dot com -Status: Closed +Status: Assigned Bug Type: Arrays related Operating System: * PHP Version: 5CVS-2005-11-09 (cvs) Assigned To: dmitry New Comment: The bug still exists in 5.2 it need just another test script. Previous Comments: ------------------------------------------------------------------------ [2006-08-01 23:03:00] tony2001@php.net Not reproducible with 5.2-CVS. ------------------------------------------------------------------------ [2005-11-16 14:52:19] dmitry@php.net 5.1 is effected too. <?php $a = array(array('A')); //$b = &$a[0]; $a[0][] =& $a[0]; $a[0][] =& $a[0]; $a[0][0] = 'b'; var_dump($a); $a = null; $b = null; ?> The problem is in "$a[0][] =& $a[0];" operator, that creates copy of $a[0] during fetching lvalue because $a[0] is not a reference and after fetching rvalue it has refcount > 1. ------------------------------------------------------------------------ [2005-11-09 05:45:44] averagomez at hotmail dot com Description: ------------ Sorry I have a very bad english but I think the 'Reproduce code' is self-describing. Reproduce code: --------------- // ---------- This work OK: $a = array('A', & $a, & $a); $a[1][0] = 'B'; echo $a[0]; // OK : Show 'B' // ---------- But this don't work: $a = array('A'); $a[1] = & $a; $a[2] = & $a; $a[1][0] = 'B'; echo $a[0]; // Wrong: Show 'A' Expected result: ---------------- BB Actual result: -------------- BA ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35163&edit=1

« previous php.bugs (#101602) next »