Req #69155 [NEW]: reference seems incorrect when parameter is passed by expression

From: Date: Mon, 02 Mar 2015 09:47:38 +0000
Subject: Req #69155 [NEW]: reference seems incorrect when parameter is passed by expression
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191033@lists.php.net to get a copy of this message
From:             leejqy at 163 dot com
Operating system: linux/windows
PHP version:      5.4.38
Package:          Scripting Engine problem
Bug Type:         Feature/Change Request
Bug description:reference seems incorrect when parameter is passed by expression

Description:
------------
When a parameter(declared as reference) is passed by mixing an
expression & assignment, the paramter actually passed seems to be the
expression, not the variable itself.

PHP version tested: 5.4.37 & 5.5.18.

Test script:
---------------
function test (&$a)
{
    $a = 10;
}
test ($a = 20);
echo $a;


Expected result:
----------------
10

Actual result:
--------------
20

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



Thread (2 messages)

« previous php.bugs (#191033) next »