Skip to content

Commit 65aed79

Browse files
committed
Fixed bug #80900
SCCP optimization marks the wrong target feasible when the constant is of the incorrect type.
1 parent b7a298b commit 65aed79

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

Zend/Optimizer/sccp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ static void sccp_mark_feasible_successors(
19421942
scdf_mark_edge_feasible(scdf, block_num, target);
19431943
return;
19441944
}
1945-
s = 0;
1945+
s = block->successors_count - 1;
19461946
break;
19471947
}
19481948
default:

ext/opcache/tests/bug80900.phpt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Bug 80900: Switch constant with incorrect type
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
opcache.opt_debug_level=0x20000
8+
--EXTENSIONS--
9+
opcache
10+
--FILE--
11+
<?php
12+
function testWithVar() {
13+
$booleanVar = false;
14+
switch ($booleanVar) {
15+
case 'a_test_case':
16+
echo 'inside testWithVar - "a_test_case"';
17+
break;
18+
case 'b_test_case':
19+
echo 'inside testWithVar - "b_test_case"';
20+
break;
21+
case 'c_test_case':
22+
echo 'inside testWithVar - "c_test_case"';
23+
break;
24+
default:
25+
echo 'inside testWithVar - "default"';
26+
break;
27+
}
28+
echo PHP_EOL;
29+
}
30+
testWithVar();
31+
?>
32+
--EXPECTF--
33+
$_main:
34+
; (lines=3, args=0, vars=0, tmps=0)
35+
; (after optimizer)
36+
; %sbug80900.php:1-22
37+
0000 INIT_FCALL 0 80 string("testwithvar")
38+
0001 DO_UCALL
39+
0002 RETURN int(1)
40+
41+
testWithVar:
42+
; (lines=3, args=0, vars=0, tmps=0)
43+
; (after optimizer)
44+
; %sbug80900.php:2-19
45+
0000 ECHO string("inside testWithVar - "default"")
46+
0001 ECHO string("
47+
")
48+
0002 RETURN null
49+
inside testWithVar - "default"

0 commit comments

Comments
 (0)