diff --git a/NEWS b/NEWS index f355b98c61d..3a71834043a 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.2.6 +- Core: + . Fix inconsistent float negation in constant expressions. (ilutov) + - DOM: . Fixed bug #80602 (Segfault when using DOMChildNode::before()). (Nathan Freeman) diff --git a/Zend/tests/unary_minus_const_expr_consistency.phpt b/Zend/tests/unary_minus_const_expr_consistency.phpt new file mode 100644 index 00000000000..c8175df8bed --- /dev/null +++ b/Zend/tests/unary_minus_const_expr_consistency.phpt @@ -0,0 +1,16 @@ +--TEST-- +Unary minus constant expression consistency +--FILE-- + +--EXPECT-- +float(-0) +float(-0) diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 6130d9da93b..2e4edeee5d9 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -676,8 +676,8 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_ex(zval *result, zend_ast *as if (UNEXPECTED(zend_ast_evaluate(&op2, ast->child[0], scope) != SUCCESS)) { ret = FAILURE; } else { - ZVAL_LONG(&op1, 0); - ret = sub_function(result, &op1, &op2); + ZVAL_LONG(&op1, -1); + ret = mul_function(result, &op1, &op2); zval_ptr_dtor_nogc(&op2); } break;