Bug #72508 [NEW]: strange references after recursive function call and "switch" statement

From: Date: Tue, 28 Jun 2016 05:59:06 +0000
Subject: Bug #72508 [NEW]: strange references after recursive function call and "switch" statement
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201879@lists.php.net to get a copy of this message
From: aleksander dot vladishev at zabbix dot com Operating system: ubuntu-16.04-server-amd64 PHP version: 7.0.8 Package: Scripting Engine problem Bug Type: Bug Bug description:strange references after recursive function call and "switch" statement Description: ------------ This regression was introduced in 7.0.x, and worked perfectly otherwise in previous versions (5.6.x). It can be reproduced with "default:" case only. Test script: --------------- <?php function check_data(&$var) { if (is_array($var)) { foreach ($var as $key => $val) { check_data($var[$key]); } } } $data = ['values' => [['type' => '4']]]; check_data($data); $values = $data['values']; foreach ($values as &$value) { switch ($value['type']) { default: $value['value'] = true; } } unset($value); echo var_dump($values)."\n".var_dump($data)."\n"; Expected result: ---------------- array(1) { [0]=> array(2) { ["type"]=> string(1) "4" ["value"]=> bool(true) } } array(1) { ["values"]=> array(1) { [0]=> array(1) { ["type"]=> string(1) "4" } } } Actual result: -------------- array(1) { [0]=> array(2) { ["type"]=> &string(1) "4" ["value"]=> bool(true) } } array(1) { ["values"]=> array(1) { [0]=> array(1) { ["type"]=> &string(1) "4" } } } -- Edit bug report at https://bugs.php.net/bug.php?id=72508&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72508&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72508&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72508&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72508&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72508&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72508&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72508&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72508&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72508&r=support Expected behavior: https://bugs.php.net/fix.php?id=72508&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72508&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72508&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72508&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72508&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72508&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72508&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72508&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72508&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72508&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72508&r=mysqlcfg

« previous php.bugs (#201879) next »