#25951 [NEW]: Error suppression operator + reference return statement => corrupt func. params

From: Date: Wed, 22 Oct 2003 13:43:40 +0000
Subject: #25951 [NEW]: Error suppression operator + reference return statement => corrupt func. params
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-49343@lists.php.net to get a copy of this message
From:             dand at codemonkey dot ro
Operating system: Debian Linux 3.0
PHP version:      4.3.3
PHP Bug Type:     Unknown/Other Function
Bug description:  Error suppression operator + reference return statement => corrupt func. params

Description:
------------
The code + results should be pretty self explainatory.

A workaround would be to remove either the reference operator "&
getElement" or the error suppression operator "@$this->hash".

PS: I know that using @ instead of isset() is wrong, especially in this
situation...

Reproduce code:
---------------
class Foo {
	var $hash;

	function  & getElement($name) {
		return @$this->hash[$name];
	}	

	function bar($a, $b, $c, $d)
	{
		print "BAR: $a, $b, $c, $d<br>";
	}	
}

$f = new Foo();

for ($k = 0; $k < 3; $k++) {
	$t = $f->getElement($k);
	$f->bar(1, 2, 3, 4);
}

Expected result:
----------------
BAR: 1, 2, 3
BAR: 1, 2, 3
BAR: 1, 2, 3

Actual result:
--------------
BAR: 1, 2, 3
BAR: 3, 3, 3
BAR: 3, 3, 3

[If it helps, in PHP 4.1.2 the actual result is:
BAR: 3, 3, 3
BAR: 3, 3, 3
BAR: 3, 3, 3
]

-- 
Edit bug report at http://bugs.php.net/?id=25951&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25951&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25951&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25951&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25951&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25951&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25951&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25951&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25951&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25951&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25951&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25951&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25951&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25951&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25951&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25951&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25951&r=float


Thread (4 messages)

« previous php.bugs (#49343) next »