Merge branch 'PHP-8.0' into PHP-8.1

* PHP-8.0:
  Fixed incorrect narrowing to double
This commit is contained in:
Dmitry Stogov 2021-11-25 15:15:01 +03:00
commit b1a1ed380f
2 changed files with 26 additions and 1 deletions

View File

@ -3968,7 +3968,7 @@ static bool can_convert_to_double(
for (phi = var->phi_use_chain; phi; phi = zend_ssa_next_use_phi(ssa, var_num, phi)) {
/* Check that narrowing can actually be useful */
type = ssa->var_info[phi->ssa_var].type;
if ((type & MAY_BE_ANY) & ~(MAY_BE_LONG|MAY_BE_DOUBLE)) {
if (type & ((MAY_BE_ANY|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) {
return 0;
}

View File

@ -0,0 +1,25 @@
--TEST--
JIT ASSIGN: incorrect narrowing to double
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.protect_memory=1
--FILE--
<?php
function test(){
$x = (object)['x'=>0];
for($i=0;$i<10;$i++){
+$a;
$a=$x->x;
$a=7;
}
}
test()
?>
DONE
--EXPECTF--
Warning: Undefined variable $a in %sassign_047.php on line 5
DONE