php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53356 Allow use function return value in write context
Submitted: 2010-11-19 15:50 UTC Modified: 2015-04-06 09:30 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: lifinsky at yandex dot ru Assigned:
Status: Re-Opened Package: Scripting Engine problem
PHP Version: 5.3.3 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-11-19 15:50 UTC] lifinsky at yandex dot ru
Description:
------------
Allow use function return value in write context if this function return value by reference (Such as c or c++)

Test script:
---------------
function &test() {
	static $a = 0;
	return $a;
}

print(++test());
print(++test());
print(++test());


Expected result:
----------------
123

Actual result:
--------------
Fatal error

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-27 14:24 UTC] tyrael@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: tyrael
 [2015-03-27 14:24 UTC] tyrael@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

this will be supported in php7 as you can see here: http://3v4l.org/lCOIR
 [2015-03-27 14:30 UTC] nikic@php.net
-Status: Closed +Status: Re-Opened
 [2015-03-27 14:30 UTC] nikic@php.net
That change was not intentional and we may want to revert it. Especially given how it currently allows you to write this even if the function does not return by reference.
 [2015-04-06 09:30 UTC] tyrael@php.net
-Assigned To: tyrael +Assigned To:
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC