Bug #62110 [NEW]: Foreach creates a copy of the array passed by value in function

From: Date: Tue, 22 May 2012 19:56:06 +0000
Subject: Bug #62110 [NEW]: Foreach creates a copy of the array passed by value in function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-170681@lists.php.net to get a copy of this message
From:             
Operating system: Arch Linux
PHP version:      5.4.3
Package:          Performance problem
Bug Type:         Bug
Bug description:Foreach creates a copy of the array passed by value in function

Description:
------------
I also tried to execute this code on PHP 5.3.13 and PHP 5.2.17 with same
result.

All options are default.

Test script:
---------------
http://pastebin.com/caczCxuD

Expected result:
----------------
Start: 786432
Inner by_reference: 786432
Inner foreach: 786432
After by_reference: 786432
Inner by_value: 786432
Inner foreach: 786432
After by_value: 786432

Actual result:
--------------
Start: 786432
Inner by_reference: 786432
Inner foreach: 786432
After by_reference: 786432
Inner by_value: 786432
Inner foreach: 1310720
After by_value: 104857

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



Thread (4 messages)

« previous php.bugs (#170681) next »