Skip to content

Commit

Permalink
Fixed bug #74980 (Narrowing occurred during type inference)
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Jul 26, 2017
1 parent 238f837 commit 3df47c1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ PHP NEWS
. Fixed bug #74968 (PHP crashes when calling mysqli_result::fetch_object with
an abstract class). (Anatol)

- Opcache:
. Fixed bug #74980 (Narrowing occurred during type inference). (Laruence)

- Session:
. Fixed bug #74892 (Url Rewriting (trans_sid) not working on urls that start
with "#"). (Andrew Nester)
Expand Down
8 changes: 5 additions & 3 deletions ext/opcache/Optimizer/zend_inference.c
Original file line number Diff line number Diff line change
Expand Up @@ -3279,9 +3279,11 @@ int zend_infer_types_ex(const zend_op_array *op_array, const zend_script *script
zend_ssa_var_info *ssa_var_info = ssa->var_info;
int ssa_vars_count = ssa->vars_count;
int i, j;
uint32_t tmp;
uint32_t tmp, worklist_len = zend_bitset_len(ssa_vars_count);

WHILE_WORKLIST(worklist, zend_bitset_len(ssa_vars_count), j) {
while (!zend_bitset_empty(worklist, worklist_len)) {
j = zend_bitset_first(worklist, worklist_len);
zend_bitset_excl(worklist, j);
if (ssa_vars[j].definition_phi) {
zend_ssa_phi *p = ssa_vars[j].definition_phi;
if (p->pi >= 0) {
Expand Down Expand Up @@ -3340,7 +3342,7 @@ int zend_infer_types_ex(const zend_op_array *op_array, const zend_script *script
return FAILURE;
}
}
} WHILE_WORKLIST_END();
}
return SUCCESS;
}

Expand Down
30 changes: 30 additions & 0 deletions ext/opcache/tests/bug74980.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Bug #74980 (Narrowing occurred during type inference)
--INI--
opcache.enable=1
opcache.enable_cli=1
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php

class A
{

static function foo()
{
while ($undef) {
$arr[][] = NULL;
}

foreach ($arr as $a) {
bar($a + []);
}
}

}

echo "okey";
?>
--EXPECT--
okey

0 comments on commit 3df47c1

Please sign in to comment.