mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Fixed bug #80900
SCCP optimization marks the wrong target feasible when the constant is of the incorrect type. Closes GH-6861.
This commit is contained in:
parent
976e71a2fa
commit
7c6cf09463
3
NEWS
3
NEWS
@ -6,6 +6,9 @@ PHP NEWS
|
||||
. Fixed bug #80933 (SplFileObject::DROP_NEW_LINE is broken for NUL and CR).
|
||||
(cmb, Nikita)
|
||||
|
||||
- Opcache:
|
||||
. Fixed bug #80900 (switch statement behavior inside function). (twosee)
|
||||
|
||||
29 Apr 2021, PHP 7.4.18
|
||||
|
||||
- Core:
|
||||
|
@ -2006,7 +2006,7 @@ static void sccp_mark_feasible_successors(
|
||||
scdf_mark_edge_feasible(scdf, block_num, target);
|
||||
return;
|
||||
}
|
||||
s = 0;
|
||||
s = block->successors_count - 1;
|
||||
break;
|
||||
case ZEND_SWITCH_STRING:
|
||||
if (Z_TYPE_P(op1) == IS_STRING) {
|
||||
@ -2024,7 +2024,7 @@ static void sccp_mark_feasible_successors(
|
||||
scdf_mark_edge_feasible(scdf, block_num, target);
|
||||
return;
|
||||
}
|
||||
s = 0;
|
||||
s = block->successors_count - 1;
|
||||
break;
|
||||
default:
|
||||
for (s = 0; s < block->successors_count; s++) {
|
||||
|
56
ext/opcache/tests/bug80900.phpt
Normal file
56
ext/opcache/tests/bug80900.phpt
Normal file
@ -0,0 +1,56 @@
|
||||
--TEST--
|
||||
Bug 80900: Switch constant with incorrect type
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.optimization_level=-1
|
||||
--SKIPIF--
|
||||
<?php require_once('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
function switchLong() {
|
||||
$var = 'foo';
|
||||
/* The number of case clauses needs to be greater than 5,
|
||||
* otherwise it will not be compiled into SWITCH_LONG. */
|
||||
switch ($var) {
|
||||
case 1:
|
||||
echo 'no1';
|
||||
break;
|
||||
case 2:
|
||||
echo 'no2';
|
||||
break;
|
||||
case 3:
|
||||
echo 'no3';
|
||||
break;
|
||||
case 4:
|
||||
echo 'no4';
|
||||
break;
|
||||
case 5:
|
||||
echo 'no5';
|
||||
break;
|
||||
default:
|
||||
echo 'yes';
|
||||
break;
|
||||
}
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
function switchString() {
|
||||
$var = false;
|
||||
switch ($var) {
|
||||
case 'string':
|
||||
echo 'no';
|
||||
break;
|
||||
default:
|
||||
echo 'yes';
|
||||
break;
|
||||
}
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
switchLong();
|
||||
switchString();
|
||||
?>
|
||||
--EXPECT--
|
||||
yes
|
||||
yes
|
Loading…
Reference in New Issue
Block a user