Bug #72215 [Opn->Csd]: Wrong return value if var modified in finally

From: Date: Wed, 13 Jul 2016 12:09:06 +0000
Subject: Bug #72215 [Opn->Csd]: Wrong return value if var modified in finally
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202277@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72215&edit=1

 ID:                 72215
 Updated by:         dmitry@php.net
 Reported by:        nikic@php.net
 Summary:            Wrong return value if var modified in finally
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3b8cb2119b33ed6b7701d78d32eed63593cf61ff
Log: Fixed bug #72347 (VERIFY_RETURN type casts visible in finally) Fixed bug #72216 (Return by
reference with finally is not memory safe) Fixed bug #72215 (Wrong return value if var modified in
finally)


Previous Comments:
------------------------------------------------------------------------
[2016-05-16 09:01:40] nikic@php.net

@laruence: Yes, it's not entirely unreasonable. But I think it's very odd that
"return $a + 1" will use the old value of $a, while "return $a" will use the new
one...

This also ties in with our other problems with finally returns (the leak because we can't track
liveness ranges, and bug #72216) -- if we fix any of them we'll probably automatically fix
everything :)

------------------------------------------------------------------------
[2016-05-16 03:26:54] laruence@php.net

I think the current way also makes sense, not a big issue here, it depends how we explain it..

------------------------------------------------------------------------
[2016-05-13 23:26:25] nikic@php.net

Description:
------------
Should return 1, the unmodified value, but returns 2.

Test script:
---------------
<?php

function test() {
    $a = 1;
    try {
        return $a;
    } finally {
        $a = 2;
    }
}
var_dump(test());




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



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


Thread (4 messages)

« previous php.bugs (#202277) next »