summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-07-03 10:22:41 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-07-03 10:22:41 +0200
commitfa1a03f7a2fb62d44180a91f13409d21a9ba0672 (patch)
tree8b27ff0e572f5d3228648006c4d6b4fc27796d5c /ext
parentf71268ac67bc540b29b3ceff80f9673c4a6fcecb (diff)
parentc0924cf67d81c9bdf4451c4e00fb956cf154a141 (diff)
downloadphp-git-fa1a03f7a2fb62d44180a91f13409d21a9ba0672.tar.gz
Merge branch 'PHP-7.4'
Diffstat (limited to 'ext')
-rw-r--r--ext/opcache/Optimizer/sccp.c2
-rw-r--r--ext/opcache/tests/bug78230.phpt29
2 files changed, 30 insertions, 1 deletions
diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c
index 8cbe72645c..9715f3e238 100644
--- a/ext/opcache/Optimizer/sccp.c
+++ b/ext/opcache/Optimizer/sccp.c
@@ -2326,7 +2326,7 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var,
if (opline->opcode == ZEND_DO_ICALL) {
removed_ops = remove_call(ctx, opline, ssa_op);
} else if (opline->opcode == ZEND_TYPE_CHECK
- && ssa_op->op1_use >= 0
+ && opline->op1_type & (IS_VAR|IS_TMP_VAR)
&& !value_known(&ctx->values[ssa_op->op1_use])) {
/* For TYPE_CHECK we may compute the result value without knowing the
* operand, based on type inference information. Make sure the operand is
diff --git a/ext/opcache/tests/bug78230.phpt b/ext/opcache/tests/bug78230.phpt
new file mode 100644
index 0000000000..38cc684995
--- /dev/null
+++ b/ext/opcache/tests/bug78230.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #78230: Incorrect type check optimization
+--FILE--
+<?php
+
+function test($x) {
+ $y = (array) $x;
+ var_dump(is_array($y));
+}
+
+$ary = [1, 2];
+$ary[] = 3;
+test($ary);
+$ary[] = 4;
+var_dump($ary);
+
+?>
+--EXPECT--
+bool(true)
+array(4) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+}