php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37270 incompatibility 4.4.2 vs. 5.1.3 ?
Submitted: 2006-05-02 06:43 UTC Modified: 2006-05-03 06:57 UTC
From: lacak at users dot sourceforge dot net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.1.3 OS: Windows 98
Private report: No CVE-ID: None
 [2006-05-02 06:43 UTC] lacak at users dot sourceforge dot net
Description:
------------
See please the php reproduce code.

In PHP 4.4.2 returns "Expected result"
In PHP 5.1.3 returns "Actual result"

Reproduce code:
---------------
<?php
function a(&$p) {
 $p=array("a"=>"1", "b"=>2);
}

function b(&$p) {
 $p=1;
}

a($v1=array());
print_r($v1);

b($v2=0);
var_dump($v2);
?>

Expected result:
----------------
Array ( [a] => 1 [b] => 2 ) int(1)

Actual result:
--------------
Array ( ) int(0)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-02 07:10 UTC] mike@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Turn on error displaying and you'll see "only variables can be passed by reference". "$v=..." as function argument is an expression.

Please use a support channel in future.
 [2006-05-03 05:23 UTC] lacak at users dot sourceforge dot net
Yes I understand, that $v=0 in f($v=0) is expression in POV of php, but in POV of user it is :
1. initializing variable
2. passing this variable as by reference argument to function

And second, why this produces no error message (no warning, no notice; error_reporting=E_ALL) under 4.4.2 and works it as expected ?
This seems to me like regression problem between 4.4 -> 5.1 ?
 [2006-05-03 06:57 UTC] mike@php.net
It will cause memory corruptions.

Yes, I know it's unfortunate, but ATM it's not fixable.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 20 18:00:03 2025 UTC