Bug #72369 [NEW]: array_merge() produces references in PHP7

From: Date: Thu, 09 Jun 2016 11:35:00 +0000
Subject: Bug #72369 [NEW]: array_merge() produces references in PHP7
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201509@lists.php.net to get a copy of this message
From:             tony2001
Operating system: *
PHP version:      7.0.8RC1
Package:          Arrays related
Bug Type:         Bug
Bug description:array_merge() produces references in PHP7

Description:
------------
array_merge() changed behavior in PHP7, the reproduce script below
produces references, which it didn't do in PHP5.

Test script:
---------------
<?php
$x = 'xxx';
$d = ['test' => &$x];
unset($x);
$a = ['test' => 'yyy'];
$a = array_merge($a, $d);
debug_zval_dump($a);
?>

Expected result:
----------------
array(1) refcount(2){
  ["test"]=>
  string(3) "xxx" refcount(2)
}


Actual result:
--------------
array(1) refcount(2){
  ["test"]=>
  &string(3) "xxx" refcount(1)
}


-- 
Edit bug report at https://bugs.php.net/bug.php?id=72369&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72369&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72369&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72369&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72369&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72369&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72369&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72369&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72369&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72369&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72369&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72369&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72369&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72369&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72369&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72369&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72369&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72369&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72369&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72369&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72369&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#201509) next »