summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-07-03 10:19:31 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-07-03 10:20:07 +0200
commit4892bbc167dfa0ea188baebbce538225f4a0455a (patch)
tree78e2fcfb62b75f1ad1839730e8b1d2802be86ec0
parent5e5b7cb4d4fe72052a9408dccfee7d41063a3586 (diff)
downloadphp-git-4892bbc167dfa0ea188baebbce538225f4a0455a.tar.gz
Fixed bug #78230
-rw-r--r--NEWS8
-rw-r--r--ext/opcache/Optimizer/sccp.c1
-rw-r--r--ext/opcache/tests/bug78230.phpt29
3 files changed, 35 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index cc6a9dff91..4f6fcd22b2 100644
--- a/NEWS
+++ b/NEWS
@@ -9,9 +9,11 @@ PHP NEWS
. Fixed #69044 (discrepency between time and microtime). (krakjoe)
. Updated timelib to 2018.02. (Derick)
-- OPcache:
- . Fixed #78189 (file cache strips last character of uname hash). (cmb)
- . Fixed #78202 (Opcache stats for cache hits are capped at 32bit NUM). (cmb)
+- Opcache:
+ . Fixed bug #78189 (file cache strips last character of uname hash). (cmb)
+ . Fixed bug #78202 (Opcache stats for cache hits are capped at 32bit NUM).
+ (cmb)
+ . Fixed bug #78230 (Incorrect type check optimization). (Nikita)
- PCRE:
. Fixed bug #78197 (PCRE2 version check in configure fails for "##.##-xxx"
diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c
index ac3247076e..1ec3a51532 100644
--- a/ext/opcache/Optimizer/sccp.c
+++ b/ext/opcache/Optimizer/sccp.c
@@ -2204,6 +2204,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
+ && 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)
+}