#21600 [Csd]: assign by reference function call changes variable contents

From: Date: Mon, 24 Feb 2003 15:57:42 +0000
Subject: #21600 [Csd]: assign by reference function call changes variable contents
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-34102@lists.php.net to get a copy of this message
 ID:               21600
 Updated by:       sniper@php.net
 Reported By:      jhpacker at yahoo dot com
 Status:           Closed
 Bug Type:         Scripting Engine problem
 Operating System: Redhat 7.3, 8, W2k server
 PHP Version:      4.3.0, 5.0.0
 New Comment:

The fix will be in PHP 5.



Previous Comments:
------------------------------------------------------------------------

[2003-02-16 13:20:01] zeev@php.net

This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

(Zend Engine 2)

------------------------------------------------------------------------

[2003-02-03 06:12:38] sniper@php.net

The tests/lang/bug21600.phpt fails for me and I have 
bison 1.28..


------------------------------------------------------------------------

[2003-02-02 15:42:53] k.schroeder@php.net

tests/lang/bug21600.phpt also failed on W2k server with latest win32
snap:

---- EXPECTED OUTPUT
array(1) {
  ["foo"]=>
  string(4) "test"
}
array(1) {
  ["foo"]=>
  string(4) "test"
}
---- ACTUAL OUTPUT
array(1) {
  ["foo"]=>
  &string(4) "test"
}
array(1) {
  ["foo"]=>
  string(4) "test"
}
---- FAILED

------------------------------------------------------------------------

[2003-01-31 10:52:23] moriyoshi@php.net

I noticed this issue has something to do with the version of bison used
in a build.

Below is just my assumption:

1.28 => works
1.35 => works
1.75 => doesn't work
1.875 => ???




------------------------------------------------------------------------

[2003-01-23 16:44:49] jkkn at tv2 dot dk

Here is a simular problem - it seem to be a problem with referencing to
values from functions that not themselfs return reference.

<?php

class Person {

    var $name;

    function Person($name) {
        $this->name = $name;
        $wiefewfjwefjwefwef =& $this->getName(); // <-- this line
destroys $this->name and eventually crashes apache+php
    }
    
    function /*&*/ getName() {
        return $this->name;
    }
    
}

$kent =& new Person('Kent');

echo '<pre>'; print_r($kent); echo '</pre>';

echo '<p><b>PersonName: "' . $kent->getName() .
'"</b></p>';


?>

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/21600

-- 
Edit this bug report at http://bugs.php.net/?id=21600&edit=1



Thread (11 messages)

« previous php.bugs (#34102) next »