Skip to content

Commit d3812ca

Browse files
committed
Fixed bug #80255
This was a copy&paste mistake, target_block was used where follow_block was intended. Also update copy&paste mistakes in the comments.
1 parent c97da0f commit d3812ca

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ PHP NEWS
99
- IMAP:
1010
. Fixed bug #80239 (imap_rfc822_write_address() leaks memory). (cmb)
1111

12+
- Opcache:
13+
. Fixed bug #80255 (Opcache bug (bad condition result) in 8.0.0rc1). (Nikita)
14+
1215
15 Oct 2020, PHP 8.0.0RC2
1316

1417
- Core:

Zend/tests/bug80255.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #80255: Opcache bug (bad condition result) in 8.0.0rc1
3+
--FILE--
4+
<?php
5+
6+
function test($a, $b, $c) {
7+
do {
8+
if ($a && !$b) {
9+
break;
10+
} else if ($b) {
11+
echo "foo\n";
12+
}
13+
echo "bar\n";
14+
} while ($c);
15+
echo "baz\n";
16+
}
17+
18+
test(true, true, false);
19+
20+
?>
21+
--EXPECT--
22+
foo
23+
bar
24+
baz

ext/opcache/Optimizer/block_pass.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,16 +1516,16 @@ static void zend_jmp_optimization(zend_basic_block *block, zend_op_array *op_arr
15161516
target = op_array->opcodes + follow_block->start;
15171517

15181518
if (target->opcode == ZEND_JMP) {
1519-
/* JMPZNZ(X, L1, L2), L1: JMP(L3) -> JMPZNZ(X, L3, L2) */
1519+
/* JMPZNZ(X, L1, L2), L2: JMP(L3) -> JMPZNZ(X, L1, L3) */
15201520
next = follow_block->successors[0];
15211521
} else if (target->opcode == ZEND_JMPNZ &&
15221522
SAME_VAR(target->op1, last_op->op1)) {
1523-
/* JMPZNZ(X, L1, L2), L1: X = JMPNZ(X, L3) -> JMPZNZ(X, L1+1, L2) */
1523+
/* JMPZNZ(X, L1, L2), L2: X = JMPNZ(X, L3) -> JMPZNZ(X, L1, L3) */
15241524
next = follow_block->successors[0];
15251525
} else if ((target->opcode == ZEND_JMPZ || target->opcode == ZEND_JMPZNZ) &&
15261526
SAME_VAR(target->op1, last_op->op1)) {
1527-
/* JMPZNZ(X, L1, L2), L1: JMPZ(X, L3) -> JMPZNZ(X, L3, L2) */
1528-
next = target_block->successors[1];
1527+
/* JMPZNZ(X, L1, L2), L2: JMPZ(X, L3) -> JMPZNZ(X, L1, L2+1) */
1528+
next = follow_block->successors[1];
15291529
} else {
15301530
break;
15311531
}

0 commit comments

Comments
 (0)