Skip to content

Commit b1a1ed3

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fixed incorrect narrowing to double
2 parents ecc4d13 + f9518c3 commit b1a1ed3

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Zend/Optimizer/zend_inference.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3968,7 +3968,7 @@ static bool can_convert_to_double(
39683968
for (phi = var->phi_use_chain; phi; phi = zend_ssa_next_use_phi(ssa, var_num, phi)) {
39693969
/* Check that narrowing can actually be useful */
39703970
type = ssa->var_info[phi->ssa_var].type;
3971-
if ((type & MAY_BE_ANY) & ~(MAY_BE_LONG|MAY_BE_DOUBLE)) {
3971+
if (type & ((MAY_BE_ANY|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) {
39723972
return 0;
39733973
}
39743974

ext/opcache/tests/jit/assign_047.phpt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
JIT ASSIGN: incorrect narrowing to double
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
--FILE--
10+
<?php
11+
function test(){
12+
$x = (object)['x'=>0];
13+
for($i=0;$i<10;$i++){
14+
+$a;
15+
$a=$x->x;
16+
$a=7;
17+
}
18+
}
19+
test()
20+
?>
21+
DONE
22+
--EXPECTF--
23+
Warning: Undefined variable $a in %sassign_047.php on line 5
24+
DONE
25+

0 commit comments

Comments
 (0)