From:             BenBE at omorphia dot de
Operating system: Windows 2K
PHP version:      5.2.0
PHP Bug Type:     Scripting Engine problem
Bug description:  Array assignment without references

Description:
------------
When assigning an array by-value into itself PHP will insert a
self-referencing Array into the new entry

Reproduce code:
---------------
$a = array();
$a[] =& $a;
print_r($a);

$b = array();
$b[] = $b;
print_r($b);

Expected result:
----------------
array(1) {
  [0]=>
  array(1) {
    [0]=>
    array(1) {
      [0]=>
      *RECURSION*
    }
  }
}
array(1) {
  [0]=>
  array(0) {
  }
}
$b[0] should contain an empty array because $b was assigned by-value, i.e.
should get copied.

Actual result:
--------------
array(1) {
  [0]=>
  array(1) {
    [0]=>
    array(1) {
      [0]=>
      *RECURSION*
    }
  }
}
array(1) {
  [0]=>
  array(1) {
    [0]=>
    array(1) {
      [0]=>
      *RECURSION*
    }
  }
}

Comparing the references (see my entry regarding Spotting References) you
find that $b and $b[0] are different pointers and $b[0] is an array like
the one created in $a.

-- 
Edit bug report at http://bugs.php.net/?id=40050&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40050&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40050&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40050&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40050&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40050&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40050&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40050&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40050&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40050&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40050&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40050&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40050&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40050&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40050&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40050&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40050&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40050&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40050&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40050&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40050&r=mysqlcfg

Reply via email to