Skip to content

Fixed bug #80900 #6861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/opcache/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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++) {
Expand Down
56 changes: 56 additions & 0 deletions ext/opcache/tests/bug80900.phpt
Original file line number Diff line number Diff line change
@@ -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