Skip to content

Commit 4892bbc

Browse files
committed
Fixed bug #78230
1 parent 5e5b7cb commit 4892bbc

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

NEWS

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ PHP NEWS
99
. Fixed #69044 (discrepency between time and microtime). (krakjoe)
1010
. Updated timelib to 2018.02. (Derick)
1111

12-
- OPcache:
13-
. Fixed #78189 (file cache strips last character of uname hash). (cmb)
14-
. Fixed #78202 (Opcache stats for cache hits are capped at 32bit NUM). (cmb)
12+
- Opcache:
13+
. Fixed bug #78189 (file cache strips last character of uname hash). (cmb)
14+
. Fixed bug #78202 (Opcache stats for cache hits are capped at 32bit NUM).
15+
(cmb)
16+
. Fixed bug #78230 (Incorrect type check optimization). (Nikita)
1517

1618
- PCRE:
1719
. Fixed bug #78197 (PCRE2 version check in configure fails for "##.##-xxx"

ext/opcache/Optimizer/sccp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,6 +2204,7 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var,
22042204
if (opline->opcode == ZEND_DO_ICALL) {
22052205
removed_ops = remove_call(ctx, opline, ssa_op);
22062206
} else if (opline->opcode == ZEND_TYPE_CHECK
2207+
&& opline->op1_type & (IS_VAR|IS_TMP_VAR)
22072208
&& !value_known(&ctx->values[ssa_op->op1_use])) {
22082209
/* For TYPE_CHECK we may compute the result value without knowing the
22092210
* operand, based on type inference information. Make sure the operand is

ext/opcache/tests/bug78230.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #78230: Incorrect type check optimization
3+
--FILE--
4+
<?php
5+
6+
function test($x) {
7+
$y = (array) $x;
8+
var_dump(is_array($y));
9+
}
10+
11+
$ary = [1, 2];
12+
$ary[] = 3;
13+
test($ary);
14+
$ary[] = 4;
15+
var_dump($ary);
16+
17+
?>
18+
--EXPECT--
19+
bool(true)
20+
array(4) {
21+
[0]=>
22+
int(1)
23+
[1]=>
24+
int(2)
25+
[2]=>
26+
int(3)
27+
[3]=>
28+
int(4)
29+
}

0 commit comments

Comments
 (0)