com php-src: Fix partial array handling in FE_RESET edge feasibility: ext/opcache/Optimizer/sccp.c ext/opcache/t ests/bug78015.phpt

From: Date: Tue, 21 May 2019 14:59:27 +0000
Subject: com php-src: Fix partial array handling in FE_RESET edge feasibility: ext/opcache/Optimizer/sccp.c ext/opcache/t ests/bug78015.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-106265@lists.php.net to get a copy of this message
Commit: fc4836b193666958844e50bc35b93cc2da08b91c Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 21 May 2019 16:59:27 +0200 Parents: cd188d0398923fa4d49d45db3be3530598ac78d2 Branches: PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fc4836b193666958844e50bc35b93cc2da08b91c Log: Fix partial array handling in FE_RESET edge feasibility Changed paths: M ext/opcache/Optimizer/sccp.c M ext/opcache/tests/bug78015.phpt Diff: diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index 81c629b..22f8355 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -1909,7 +1909,10 @@ static void sccp_mark_feasible_successors( break; case ZEND_FE_RESET_R: case ZEND_FE_RESET_RW: - if (Z_TYPE_P(op1) != IS_ARRAY && !IS_PARTIAL_ARRAY(op1)) { + /* A non-empty partial array is definitely non-empty, but an + * empty partial array may be non-empty at runtime. */ + if (Z_TYPE_P(op1) != IS_ARRAY || + (IS_PARTIAL_ARRAY(op1) && zend_hash_num_elements(Z_ARR_P(op1)) == 0)) { scdf_mark_edge_feasible(scdf, block_num, block->successors[0]); scdf_mark_edge_feasible(scdf, block_num, block->successors[1]); return; diff --git a/ext/opcache/tests/bug78015.phpt b/ext/opcache/tests/bug78015.phpt index e93c9ce..a9feb82 100644 --- a/ext/opcache/tests/bug78015.phpt +++ b/ext/opcache/tests/bug78015.phpt @@ -48,12 +48,23 @@ function test6() { return $d; } +function test7() { + global $x; + $a = ['b' => [$x]]; + $y = 1; + foreach ($a['b'] as $_) { + $y = 2; + } + return $y; +} + var_dump(test1()); var_dump(test2()); var_dump(test3()); var_dump(test4()); var_dump(test5()); var_dump(test6()); +var_dump(test7()); ?> --EXPECTF-- @@ -71,3 +82,4 @@ bool(true) Notice: Array to string conversion in %s on line %d string(11) "Arrayfoobar" +int(2)

« previous php.cvs (#106265) next »