Bug #49348 [Com]: Uninitialized ++$foo->bar; does not cause a notice (but ++$bar; does!)

From: Date: Fri, 29 Mar 2013 20:07:33 +0000
Subject: Bug #49348 [Com]: Uninitialized ++$foo->bar; does not cause a notice (but ++$bar; does!)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-178184@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49348&edit=1

 ID:                 49348
 Comment by:         bugs dot php dot net at majkl578 dot cz
 Reported by:        BelStudent at yandex dot ru
 Summary:            Uninitialized ++$foo->bar; does not cause a notice
                     (but ++$bar; does!)
 Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   *
 PHP Version:        5.*, 6
 Assigned To:        stas
 Block user comment: N
 Private report:     N

 New Comment:

The message is not consistent with the other one triggered in similar case.

Consider the following code:
$x = new stdClass();
echo $x->foo++;
echo $x->bar;

It triggers two notices:
Notice: Undefined property: foo
Notice: Undefined property: stdClass::$bar

The first one was added by fix for this bug and is wrong. It should be same as the other one (should
contain classname and dollar).


Previous Comments:
------------------------------------------------------------------------
[2013-02-21 08:58:40] stas@php.net

Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0c6d903ce7615a7197cb997d67d98058c3ec5d6a
Log: fix bug #49348 - issue notice on get_property_ptr_ptr when used for read

------------------------------------------------------------------------
[2013-02-20 08:35:21] dmitry@php.net

I think the fix is fine, but it may go only into 5.5 and above.

------------------------------------------------------------------------
[2013-02-19 09:18:04] stas@php.net

Potential fix in this pull: https://github.com/php/php-src/pull/281

------------------------------------------------------------------------
[2013-02-19 04:59:16] stas@php.net

The problem here is that get_property_ptr_ptr does not produce notices. It doesn't 
because it does not know the fetch type - in some cases it's BP_VAR_W, then it 
shouldn't produce notice, in some it's BP_VAR_RW and then it should. However 
get_property_ptr_ptr doesn't have a parameter to pass this info.

Looks like such parameter needs to be added...

------------------------------------------------------------------------
[2009-09-01 08:41:52] sjoerd@php.net

I was talking about this:
http://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_execute.c?revision=286362&view=markup#l251

With ++$foo, type is BP_VAR_RW, which makes sense and gives a notice. With ++$this->foo, it is
BP_VAR_W.

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


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

    https://bugs.php.net/bug.php?id=49348


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


Thread (14 messages)

« previous php.bugs (#178184) next »