ID:               44658
 User updated by:  mo at nevali dot net
 Reported By:      mo at nevali dot net
 Status:           Bogus
 Bug Type:         Arrays related
 Operating System: FreeBSD 6
 PHP Version:      5.2.5
 New Comment:

Thank you!

That makes perfect sense, and explains what jani meant by “references 
are not pointers”.


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

[2008-04-23 07:37:52] [EMAIL PROTECTED]

[EMAIL PROTECTED] /var/cvs/php.net/php5.3-dev $ sapi/cli/php -r '$v = 2; $a =
array("k" => &$v); $b = $a; $b["k"]++; echo $v;'
3

When arrays get copied, the elements that are references are kept as
references.

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

[2008-04-22 22:36:07] mo at nevali dot net

Okay, let me rephrase, because I'm obviously not being clear about 
something or other.

Line 12 of the testcase is the following:

$this->stuff =& $this->thing['stuff'];

If this line is commented out, the output changes (to my “expected 
result”). If this line is uncommented, the output is as per your 
“expected result”.

Foo::$stuff is not referenced anywhere (beyond its initial 
declaration) except for this line.

Your statement “references are not pointers” to me, as an experienced 
C programmer, suggests that under no circumstances, except for the 
assignment of object instances, should the following result in $b 
being a reference to $a:

$b = $a;

In the testcase (tested on PHP 5.2.5 with debugging enabled, and PHP 
5.1.6 with debugging enabled, both command-line and Apache 2 Handler 
SAPIs), line 24 behaves as though it were written:

$this->thing2 =& $foo->thing;

…if, and only if, line 12 is uncommented. Otherwise, it behaves as it 
is written:

$this->thing2 = $foo->thing;

There is NO documented reason why this behaviour should occur.

Now, if you _still_ think this is bogus, I'd really appreciate an 
explanation, with appropriate references to the documentation, as to 
why it's bogus, because if it is I'm evidently a simpleton who can't 
read and I'm now becoming slightly frustrated by both this issue and 
the unhelpfully terse responses to it.

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

[2008-04-21 06:23:59] [EMAIL PROTECTED]

FYI: I did run your (bogus) testcase.

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

[2008-04-11 08:40:49] mo at nevali dot net

If this bug has been marked as bogus, does it mean it's going to get 
summarily ignored from here on in?

It would be nice if somebody could actually try _running_ the test-case

instead of dismissing it out of hand; aspects of the behaviour are 
clearly incorrect (notably the inconsistency), even if it's the case 
that my summary of it is wrong.

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

[2008-04-07 12:37:27] mo at nevali dot net

My apologies, in my previous follow-up, I meant to write “$foo->stuff”

where I wrote “$foo->thing2”. In my testcase, there's no such property

as $foo->thing2!

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

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/44658

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

Reply via email to