mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix incorrect optimization of ASSIGN_OP may lead to incorrect result (sub assign -> pre dec conversion for null values)
This commit is contained in:
commit
ce861373b9
@ -1647,7 +1647,7 @@ void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx
|
||||
&& Z_TYPE_P(CT_CONSTANT_EX(op_array, opline->op2.constant)) == IS_LONG
|
||||
&& Z_LVAL_P(CT_CONSTANT_EX(op_array, opline->op2.constant)) == 1
|
||||
&& ssa->ops[op_1].op1_use >= 0
|
||||
&& !(ssa->var_info[ssa->ops[op_1].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) {
|
||||
&& !(ssa->var_info[ssa->ops[op_1].op1_use].type & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) {
|
||||
|
||||
// op_1: ASSIGN_SUB #?.CV [undef,null,int,foat] -> #v.CV, int(1) => PRE_DEC #?.CV ->#v.CV
|
||||
|
||||
|
18
ext/opcache/tests/opt/assign_op_002.phpt
Normal file
18
ext/opcache/tests/opt/assign_op_002.phpt
Normal file
@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
ASSIGN_OP 002: Incorrect optimization of ASSIGN_OP may lead to incorrect result (sub assign -> pre dec conversion for null values)
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.optimization_level=-1
|
||||
--FILE--
|
||||
<?php
|
||||
function foo(int $a = null) {
|
||||
$a -= 1;
|
||||
return $a;
|
||||
}
|
||||
var_dump(foo(2));
|
||||
var_dump(foo(null));
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
int(-1)
|
Loading…
Reference in New Issue
Block a user