Bug #72774 [Opn]: Exception backtrace produces wrong integer values when passed by reference
Edit report at https://bugs.php.net/bug.php?id=72774&edit=1
ID: 72774
Updated by: cmb@php.net
Reported by: eyalt@php.net
Summary: Exception backtrace produces wrong integer values
when passed by reference
Status: Open
Type: Bug
Package: Variables related
Operating System: Linux
PHP Version: 7.0.9
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
As of PHP 7.0.0 this is expected behavior, that is described in
UPGRADING[1].
I couldn't find it being listed in the migration guide in the
manual, though, so I'm switching to doc bug.
[1] <https://github.com/php/php-src/blob/PHP-7.0.0/UPGRADING#L215-L240>
Previous Comments:
------------------------------------------------------------------------
[2016-08-07 13:56:10] eyalt@php.net
Description:
------------
Exception backtrace produces wrong integer values when passed by reference - a regression VS PHP
5.x, as can be seen in the test script.
Test script:
---------------
<pre><?php
function recurse_bug($count) {
if ($count) {
return recurse_bug(--$count); // if we use instead $count - 1, then BT will be prodcued OK on PHP
7 too
}
$e = new Exception();
print $e->getTraceAsString();
}
recurse_bug(2);
/* On PHP 5.x we will get the correct BT:
#0 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#1 /var/www/html/frontend/scrap.php(4): recurse_bug(1)
#2 /var/www/html/frontend/scrap.php(9): recurse_bug(2)
#3 {main}
On PHP 7.x we will get the following wrong BT:
#0 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#1 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#2 /var/www/html/frontend/scrap.php(9): recurse_bug(1)
#3 {main} */
Expected result:
----------------
#0 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#1 /var/www/html/frontend/scrap.php(4): recurse_bug(1)
#2 /var/www/html/frontend/scrap.php(9): recurse_bug(2)
#3 {main}
Actual result:
--------------
#0 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#1 /var/www/html/frontend/scrap.php(4): recurse_bug(0)
#2 /var/www/html/frontend/scrap.php(9): recurse_bug(1)
#3 {main} */
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72774&edit=1
Thread (3 messages)