Skip to content

Commit 7dcf853

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fixed incorrect narrowing to double
2 parents 35786e3 + b1a1ed3 commit 7dcf853

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4010,7 +4010,7 @@ static bool can_convert_to_double(
40104010
for (phi = var->phi_use_chain; phi; phi = zend_ssa_next_use_phi(ssa, var_num, phi)) {
40114011
/* Check that narrowing can actually be useful */
40124012
type = ssa->var_info[phi->ssa_var].type;
4013-
if ((type & MAY_BE_ANY) & ~(MAY_BE_LONG|MAY_BE_DOUBLE)) {
4013+
if (type & ((MAY_BE_ANY|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) {
40144014
return 0;
40154015
}
40164016

ext/opcache/tests/jit/assign_047.phpt

Lines changed: 25 additions & 0 deletions
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)