Fixed bug #74980 (Narrowing occurred during type inference)
authorXinchen Hui <laruence@gmail.com>
Wed, 26 Jul 2017 04:06:33 +0000 (12:06 +0800)
committerXinchen Hui <laruence@gmail.com>
Wed, 26 Jul 2017 04:06:33 +0000 (12:06 +0800)
NEWS
ext/opcache/Optimizer/zend_inference.c
ext/opcache/tests/bug74980.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 3e32ae06e1bc1d5871b892b871560af6c3d738fc..f3ad8e71b50618841b268a8019419589901cfba6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
index a1a6c7b611d042619b0cea336f0b4afadaa66793..508ba6c3a121251917f301c5c377d9d42e4a45da 100644 (file)
@@ -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) {
@@ -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;
 }
 
diff --git a/ext/opcache/tests/bug74980.phpt b/ext/opcache/tests/bug74980.phpt
new file mode 100644 (file)
index 0000000..40fd3cd
--- /dev/null
@@ -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