Skip to content

Commit ebb7b17

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix refcount inferemce ($a += $a returns old array with RCN)
2 parents 051b396 + 4ed10f3 commit ebb7b17

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ static zend_always_inline zend_result _zend_update_type_info(
26362636
ssa, opline->extended_value, t1, t2,
26372637
opline->opcode == ZEND_ASSIGN_OP ? ssa_op->op1_def : -1, optimization_level);
26382638
if (tmp & (MAY_BE_STRING|MAY_BE_ARRAY)) {
2639-
tmp |= MAY_BE_RC1;
2639+
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
26402640
}
26412641
if (tmp & (MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
26422642
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
JIT ASSIGN_OP: 008 Arrays merging with itself
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function test() {
11+
$a = [];
12+
for ($i = 0; $i < 2; $i++) {
13+
$a + $a += $a;
14+
$a['b'] += 1;
15+
}
16+
}
17+
test();
18+
?>
19+
DONE
20+
--EXPECTF--
21+
Warning: Undefined array key "b" in %sassign_op_008.php on line 6
22+
DONE

0 commit comments

Comments
 (0)