diff --git a/NEWS b/NEWS index 8961c76eb0fce..568b1e85a49bd 100644 --- a/NEWS +++ b/NEWS @@ -265,6 +265,7 @@ PHP NEWS http_clear_last_response_headers() that allows retrieving the same content as the magic $http_response_header variable. . Add php_base64_encode_ex() API. (Remi) + . Implemented "Raising zero to the power of negative number" RFC (Jorg Sowa) - XML: . Added XML_OPTION_PARSE_HUGE parser option. (nielsdos) diff --git a/UPGRADING b/UPGRADING index d2b21942d7a38..dd530b8cba085 100644 --- a/UPGRADING +++ b/UPGRADING @@ -352,6 +352,7 @@ PHP 8.4 UPGRADE NOTES - Standard: . Calling stream_context_set_option() with 2 arguments is deprecated. Use stream_context_set_options() instead. + . Raising zero to the power of negative number is deprecated. ======================================== 5. Changed Functions @@ -524,6 +525,7 @@ PHP 8.4 UPGRADE NOTES . Added the http_get_last_response_headers() and http_clear_last_response_headers() that allows retrieving the same content as the magic $http_response_header variable. + . Added function fpow() following rules of IEEE 754. - XSL: . Added XSLTProcessor::registerPhpFunctionNS(). diff --git a/Zend/tests/runtime_compile_time_binary_operands.phpt b/Zend/tests/runtime_compile_time_binary_operands.phpt index ef4141cd3568d..e18134283e83d 100644 --- a/Zend/tests/runtime_compile_time_binary_operands.phpt +++ b/Zend/tests/runtime_compile_time_binary_operands.phpt @@ -8,6 +8,7 @@ if (getenv("SKIP_SLOW_TESTS")) die('skip slow test'); ?> --FILE-- getMessage()); $line .= "try { $compare; $error } catch (Error \$e) { if (\$e->getMessage() !== $msg) { $error } }"; } @@ -138,7 +139,7 @@ function prepareUnaryLine($op, $cmp, $operator) { try { $result = makeParam($cmp()); $line .= "if (" . ($result === "(NAN)" ? "!is_nan($compare)" : "$compare !== $result") . ") { $error }"; - } catch (Error $e) { + } catch (Throwable $e) { $msg = makeParam($e->getMessage()); $line .= "try { $compare; $error } catch (Error \$e) { if (\$e->getMessage() !== $msg) { $error } }"; } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ae2247b29e30d..465c2420ad919 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7714,7 +7714,7 @@ static zend_string *zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_string *separator = zend_empty_string; zend_string *function = filename; char *parens = ""; - + if (CG(active_op_array) && CG(active_op_array)->function_name) { if (CG(active_op_array)->fn_flags & ZEND_ACC_CLOSURE) { /* If the parent function is a closure, don't redundantly @@ -8980,6 +8980,10 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, const zval *op1, co /* Division by zero throws an error. */ return 1; } + if ((opcode == ZEND_POW) && zval_get_long(op1) == 0 && zval_get_long(op2) < 0) { + /* 0 ** (<0) throws a division by zero error. */ + return 1; + } if ((opcode == ZEND_SL || opcode == ZEND_SR) && zval_get_long(op2) < 0) { /* Shift by negative number throws an error. */ return 1; diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 890c19c0ab223..f825e63ff699b 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1287,6 +1287,20 @@ ZEND_API zend_result ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *o } /* }}} */ +static void ZEND_COLD zend_power_base_0_exponent_lt_0_error(void) +{ + zend_error(E_DEPRECATED, "Power of base 0 and negative exponent is deprecated"); +} + +static double safe_pow(double base, double exponent) +{ + if (UNEXPECTED(base == 0.0 && exponent < 0.0)) { + zend_power_base_0_exponent_lt_0_error(); + } + + return pow(base, exponent); +} + static zend_result ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ { uint8_t type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1311,14 +1325,14 @@ static zend_result ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval --i; ZEND_SIGNED_MULTIPLY_LONG(l1, l2, l1, dval, overflow); if (overflow) { - ZVAL_DOUBLE(result, dval * pow(l2, i)); + ZVAL_DOUBLE(result, dval * safe_pow(l2, i)); return SUCCESS; } } else { i /= 2; ZEND_SIGNED_MULTIPLY_LONG(l2, l2, l2, dval, overflow); if (overflow) { - ZVAL_DOUBLE(result, (double)l1 * pow(dval, i)); + ZVAL_DOUBLE(result, (double)l1 * safe_pow(dval, i)); return SUCCESS; } } @@ -1326,17 +1340,17 @@ static zend_result ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval /* i == 0 */ ZVAL_LONG(result, l1); } else { - ZVAL_DOUBLE(result, pow((double)Z_LVAL_P(op1), (double)Z_LVAL_P(op2))); + ZVAL_DOUBLE(result, safe_pow((double)Z_LVAL_P(op1), (double)Z_LVAL_P(op2))); } return SUCCESS; } else if (EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_DOUBLE))) { - ZVAL_DOUBLE(result, pow(Z_DVAL_P(op1), Z_DVAL_P(op2))); + ZVAL_DOUBLE(result, safe_pow(Z_DVAL_P(op1), Z_DVAL_P(op2))); return SUCCESS; } else if (EXPECTED(type_pair == TYPE_PAIR(IS_LONG, IS_DOUBLE))) { - ZVAL_DOUBLE(result, pow((double)Z_LVAL_P(op1), Z_DVAL_P(op2))); + ZVAL_DOUBLE(result, safe_pow((double)Z_LVAL_P(op1), Z_DVAL_P(op2))); return SUCCESS; } else if (EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_LONG))) { - ZVAL_DOUBLE(result, pow(Z_DVAL_P(op1), (double)Z_LVAL_P(op2))); + ZVAL_DOUBLE(result, safe_pow(Z_DVAL_P(op1), (double)Z_LVAL_P(op2))); return SUCCESS; } else { return FAILURE; diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index dabb9fc1434a5..dd1f59c64c005 100644 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -3274,6 +3274,11 @@ function fmod(float $num1, float $num2): float {} */ function fdiv(float $num1, float $num2): float {} +/** + * @compile-time-eval + */ +function fpow(float $num1, float $num2): float {} + /* microtime.c */ #ifdef HAVE_GETTIMEOFDAY diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 4556e10ada82b..b7071f5970729 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 1ef54fdebc6a206c4af3438130db0cd12a62c8b6 */ + * Stub hash: 5d8e13990ce18bebc9c7e6a0a9a7ad8b7593d35b */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -1732,6 +1732,8 @@ ZEND_END_ARG_INFO() #define arginfo_fdiv arginfo_fmod +#define arginfo_fpow arginfo_fmod + #if defined(HAVE_GETTIMEOFDAY) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_microtime, 0, 0, MAY_BE_STRING|MAY_BE_DOUBLE) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, as_float, _IS_BOOL, 0, "false") @@ -2789,6 +2791,7 @@ ZEND_FUNCTION(base_convert); ZEND_FUNCTION(number_format); ZEND_FUNCTION(fmod); ZEND_FUNCTION(fdiv); +ZEND_FUNCTION(fpow); #if defined(HAVE_GETTIMEOFDAY) ZEND_FUNCTION(microtime); #endif @@ -3428,6 +3431,7 @@ static const zend_function_entry ext_functions[] = { ZEND_RAW_FENTRY("number_format", zif_number_format, arginfo_number_format, ZEND_ACC_COMPILE_TIME_EVAL, NULL, NULL) ZEND_RAW_FENTRY("fmod", zif_fmod, arginfo_fmod, ZEND_ACC_COMPILE_TIME_EVAL, NULL, NULL) ZEND_RAW_FENTRY("fdiv", zif_fdiv, arginfo_fdiv, ZEND_ACC_COMPILE_TIME_EVAL, NULL, NULL) + ZEND_RAW_FENTRY("fpow", zif_fpow, arginfo_fpow, ZEND_ACC_COMPILE_TIME_EVAL, NULL, NULL) #if defined(HAVE_GETTIMEOFDAY) ZEND_FE(microtime, arginfo_microtime) #endif diff --git a/ext/standard/math.c b/ext/standard/math.c index f5996adcfb152..b546329259d8b 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -1389,6 +1389,20 @@ PHP_FUNCTION(fdiv) } /* }}} */ +/* {{{ Perform floating-point exponentiation with IEEE-754 semantics. */ +PHP_FUNCTION(fpow) +{ + double base, exponent; + + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_DOUBLE(base) + Z_PARAM_DOUBLE(exponent) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_DOUBLE(pow(base, exponent)); +} +/* }}} */ + /* {{{ Returns the integer quotient of the division of dividend by divisor */ PHP_FUNCTION(intdiv) { diff --git a/ext/standard/tests/math/bug45712.phpt b/ext/standard/tests/math/bug45712.phpt index 23c3b6ddd3683..4872e385582ea 100644 --- a/ext/standard/tests/math/bug45712.phpt +++ b/ext/standard/tests/math/bug45712.phpt @@ -42,7 +42,7 @@ var_dump($inf==='abc'); var_dump($inf===$inf); ?> ---EXPECT-- +--EXPECTF-- float(NAN) bool(true) bool(false) @@ -57,6 +57,8 @@ bool(false) bool(false) bool(false) bool(false) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d float(INF) bool(true) bool(false) diff --git a/ext/standard/tests/math/fpow.phpt b/ext/standard/tests/math/fpow.phpt new file mode 100644 index 0000000000000..3f3c64862e81e --- /dev/null +++ b/ext/standard/tests/math/fpow.phpt @@ -0,0 +1,362 @@ +--TEST-- +fpow() function +--FILE-- + +--EXPECT-- + 0 ** 0 = 1 + 0 ** 1 = 0 + 0 ** -1 = INF + 0 ** 1 = 0 + 0 ** -1 = INF + 0 ** 2 = 0 + 0 ** -2 = INF + 0 ** 2.1 = 0 + 0 ** -2.1 = INF + 0 ** 0.1 = 0 + 0 ** -0.1 = INF + 0 ** 0 = 1 + 0 ** -0 = 1 + 0 ** 10 = 0 + 0 ** -10 = INF + 0 ** INF = 0 + 0 ** -INF = INF + 0 ** NAN = NAN + 1 ** 0 = 1 + 1 ** 1 = 1 + 1 ** -1 = 1 + 1 ** 1 = 1 + 1 ** -1 = 1 + 1 ** 2 = 1 + 1 ** -2 = 1 + 1 ** 2.1 = 1 + 1 ** -2.1 = 1 + 1 ** 0.1 = 1 + 1 ** -0.1 = 1 + 1 ** 0 = 1 + 1 ** -0 = 1 + 1 ** 10 = 1 + 1 ** -10 = 1 + 1 ** INF = 1 + 1 ** -INF = 1 + 1 ** NAN = 1 + -1 ** 0 = 1 + -1 ** 1 = -1 + -1 ** -1 = -1 + -1 ** 1 = -1 + -1 ** -1 = -1 + -1 ** 2 = 1 + -1 ** -2 = 1 + -1 ** 2.1 = NAN + -1 ** -2.1 = NAN + -1 ** 0.1 = NAN + -1 ** -0.1 = NAN + -1 ** 0 = 1 + -1 ** -0 = 1 + -1 ** 10 = 1 + -1 ** -10 = 1 + -1 ** INF = 1 + -1 ** -INF = 1 + -1 ** NAN = NAN + 1 ** 0 = 1 + 1 ** 1 = 1 + 1 ** -1 = 1 + 1 ** 1 = 1 + 1 ** -1 = 1 + 1 ** 2 = 1 + 1 ** -2 = 1 + 1 ** 2.1 = 1 + 1 ** -2.1 = 1 + 1 ** 0.1 = 1 + 1 ** -0.1 = 1 + 1 ** 0 = 1 + 1 ** -0 = 1 + 1 ** 10 = 1 + 1 ** -10 = 1 + 1 ** INF = 1 + 1 ** -INF = 1 + 1 ** NAN = 1 + -1 ** 0 = 1 + -1 ** 1 = -1 + -1 ** -1 = -1 + -1 ** 1 = -1 + -1 ** -1 = -1 + -1 ** 2 = 1 + -1 ** -2 = 1 + -1 ** 2.1 = NAN + -1 ** -2.1 = NAN + -1 ** 0.1 = NAN + -1 ** -0.1 = NAN + -1 ** 0 = 1 + -1 ** -0 = 1 + -1 ** 10 = 1 + -1 ** -10 = 1 + -1 ** INF = 1 + -1 ** -INF = 1 + -1 ** NAN = NAN + 2 ** 0 = 1 + 2 ** 1 = 2 + 2 ** -1 = 0.5 + 2 ** 1 = 2 + 2 ** -1 = 0.5 + 2 ** 2 = 4 + 2 ** -2 = 0.25 + 2 ** 2.1 = 4.2870938501452 + 2 ** -2.1 = 0.2332582478842 + 2 ** 0.1 = 1.0717734625363 + 2 ** -0.1 = 0.93303299153681 + 2 ** 0 = 1 + 2 ** -0 = 1 + 2 ** 10 = 1024 + 2 ** -10 = 0.0009765625 + 2 ** INF = INF + 2 ** -INF = 0 + 2 ** NAN = NAN + -2 ** 0 = 1 + -2 ** 1 = -2 + -2 ** -1 = -0.5 + -2 ** 1 = -2 + -2 ** -1 = -0.5 + -2 ** 2 = 4 + -2 ** -2 = 0.25 + -2 ** 2.1 = NAN + -2 ** -2.1 = NAN + -2 ** 0.1 = NAN + -2 ** -0.1 = NAN + -2 ** 0 = 1 + -2 ** -0 = 1 + -2 ** 10 = 1024 + -2 ** -10 = 0.0009765625 + -2 ** INF = INF + -2 ** -INF = 0 + -2 ** NAN = NAN + 2.1 ** 0 = 1 + 2.1 ** 1 = 2.1 + 2.1 ** -1 = 0.47619047619048 + 2.1 ** 1 = 2.1 + 2.1 ** -1 = 0.47619047619048 + 2.1 ** 2 = 4.41 + 2.1 ** -2 = 0.22675736961451 + 2.1 ** 2.1 = 4.7496380917422 + 2.1 ** -2.1 = 0.21054235726688 + 2.1 ** 0.1 = 1.0770154403044 + 2.1 ** -0.1 = 0.92849179554696 + 2.1 ** 0 = 1 + 2.1 ** -0 = 1 + 2.1 ** 10 = 1667.9880978201 + 2.1 ** -10 = 0.0005995246616609 + 2.1 ** INF = INF + 2.1 ** -INF = 0 + 2.1 ** NAN = NAN +-2.1 ** 0 = 1 +-2.1 ** 1 = -2.1 +-2.1 ** -1 = -0.47619047619048 +-2.1 ** 1 = -2.1 +-2.1 ** -1 = -0.47619047619048 +-2.1 ** 2 = 4.41 +-2.1 ** -2 = 0.22675736961451 +-2.1 ** 2.1 = NAN +-2.1 ** -2.1 = NAN +-2.1 ** 0.1 = NAN +-2.1 ** -0.1 = NAN +-2.1 ** 0 = 1 +-2.1 ** -0 = 1 +-2.1 ** 10 = 1667.9880978201 +-2.1 ** -10 = 0.0005995246616609 +-2.1 ** INF = INF +-2.1 ** -INF = 0 +-2.1 ** NAN = NAN + 0.1 ** 0 = 1 + 0.1 ** 1 = 0.1 + 0.1 ** -1 = 10 + 0.1 ** 1 = 0.1 + 0.1 ** -1 = 10 + 0.1 ** 2 = 0.01 + 0.1 ** -2 = 100 + 0.1 ** 2.1 = 0.0079432823472428 + 0.1 ** -2.1 = 125.89254117942 + 0.1 ** 0.1 = 0.79432823472428 + 0.1 ** -0.1 = 1.2589254117942 + 0.1 ** 0 = 1 + 0.1 ** -0 = 1 + 0.1 ** 10 = 1.0E-10 + 0.1 ** -10 = 10000000000 + 0.1 ** INF = 0 + 0.1 ** -INF = INF + 0.1 ** NAN = NAN +-0.1 ** 0 = 1 +-0.1 ** 1 = -0.1 +-0.1 ** -1 = -10 +-0.1 ** 1 = -0.1 +-0.1 ** -1 = -10 +-0.1 ** 2 = 0.01 +-0.1 ** -2 = 100 +-0.1 ** 2.1 = NAN +-0.1 ** -2.1 = NAN +-0.1 ** 0.1 = NAN +-0.1 ** -0.1 = NAN +-0.1 ** 0 = 1 +-0.1 ** -0 = 1 +-0.1 ** 10 = 1.0E-10 +-0.1 ** -10 = 10000000000 +-0.1 ** INF = 0 +-0.1 ** -INF = INF +-0.1 ** NAN = NAN + 0 ** 0 = 1 + 0 ** 1 = 0 + 0 ** -1 = INF + 0 ** 1 = 0 + 0 ** -1 = INF + 0 ** 2 = 0 + 0 ** -2 = INF + 0 ** 2.1 = 0 + 0 ** -2.1 = INF + 0 ** 0.1 = 0 + 0 ** -0.1 = INF + 0 ** 0 = 1 + 0 ** -0 = 1 + 0 ** 10 = 0 + 0 ** -10 = INF + 0 ** INF = 0 + 0 ** -INF = INF + 0 ** NAN = NAN + -0 ** 0 = 1 + -0 ** 1 = -0 + -0 ** -1 = -INF + -0 ** 1 = -0 + -0 ** -1 = -INF + -0 ** 2 = 0 + -0 ** -2 = INF + -0 ** 2.1 = 0 + -0 ** -2.1 = INF + -0 ** 0.1 = 0 + -0 ** -0.1 = INF + -0 ** 0 = 1 + -0 ** -0 = 1 + -0 ** 10 = 0 + -0 ** -10 = INF + -0 ** INF = 0 + -0 ** -INF = INF + -0 ** NAN = NAN + 10 ** 0 = 1 + 10 ** 1 = 10 + 10 ** -1 = 0.1 + 10 ** 1 = 10 + 10 ** -1 = 0.1 + 10 ** 2 = 100 + 10 ** -2 = 0.01 + 10 ** 2.1 = 125.89254117942 + 10 ** -2.1 = 0.0079432823472428 + 10 ** 0.1 = 1.2589254117942 + 10 ** -0.1 = 0.79432823472428 + 10 ** 0 = 1 + 10 ** -0 = 1 + 10 ** 10 = 10000000000 + 10 ** -10 = 1.0E-10 + 10 ** INF = INF + 10 ** -INF = 0 + 10 ** NAN = NAN + -10 ** 0 = 1 + -10 ** 1 = -10 + -10 ** -1 = -0.1 + -10 ** 1 = -10 + -10 ** -1 = -0.1 + -10 ** 2 = 100 + -10 ** -2 = 0.01 + -10 ** 2.1 = NAN + -10 ** -2.1 = NAN + -10 ** 0.1 = NAN + -10 ** -0.1 = NAN + -10 ** 0 = 1 + -10 ** -0 = 1 + -10 ** 10 = 10000000000 + -10 ** -10 = 1.0E-10 + -10 ** INF = INF + -10 ** -INF = 0 + -10 ** NAN = NAN + INF ** 0 = 1 + INF ** 1 = INF + INF ** -1 = 0 + INF ** 1 = INF + INF ** -1 = 0 + INF ** 2 = INF + INF ** -2 = 0 + INF ** 2.1 = INF + INF ** -2.1 = 0 + INF ** 0.1 = INF + INF ** -0.1 = 0 + INF ** 0 = 1 + INF ** -0 = 1 + INF ** 10 = INF + INF ** -10 = 0 + INF ** INF = INF + INF ** -INF = 0 + INF ** NAN = NAN +-INF ** 0 = 1 +-INF ** 1 = -INF +-INF ** -1 = -0 +-INF ** 1 = -INF +-INF ** -1 = -0 +-INF ** 2 = INF +-INF ** -2 = 0 +-INF ** 2.1 = INF +-INF ** -2.1 = 0 +-INF ** 0.1 = INF +-INF ** -0.1 = 0 +-INF ** 0 = 1 +-INF ** -0 = 1 +-INF ** 10 = INF +-INF ** -10 = 0 +-INF ** INF = INF +-INF ** -INF = 0 +-INF ** NAN = NAN + NAN ** 0 = 1 + NAN ** 1 = NAN + NAN ** -1 = NAN + NAN ** 1 = NAN + NAN ** -1 = NAN + NAN ** 2 = NAN + NAN ** -2 = NAN + NAN ** 2.1 = NAN + NAN ** -2.1 = NAN + NAN ** 0.1 = NAN + NAN ** -0.1 = NAN + NAN ** 0 = 1 + NAN ** -0 = 1 + NAN ** 10 = NAN + NAN ** -10 = NAN + NAN ** INF = NAN + NAN ** -INF = NAN + NAN ** NAN = NAN diff --git a/ext/standard/tests/math/is_finite_basic.phpt b/ext/standard/tests/math/is_finite_basic.phpt index bc044e69eacdc..08bbadbd3babc 100644 --- a/ext/standard/tests/math/is_finite_basic.phpt +++ b/ext/standard/tests/math/is_finite_basic.phpt @@ -2,26 +2,28 @@ Test is_finite() - basic function test is_finite() --FILE-- ---EXPECT-- +--EXPECTF-- +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(true) bool(true) bool(true) diff --git a/ext/standard/tests/math/is_infinite_basic.phpt b/ext/standard/tests/math/is_infinite_basic.phpt index 0c7b07611867b..599bdd635fba1 100644 --- a/ext/standard/tests/math/is_infinite_basic.phpt +++ b/ext/standard/tests/math/is_infinite_basic.phpt @@ -21,7 +21,8 @@ for ($i = 0; $i < count($values); $i++) { var_dump($res); } ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(false) bool(false) bool(false) diff --git a/ext/standard/tests/math/is_nan_basic.phpt b/ext/standard/tests/math/is_nan_basic.phpt index 65555e25ae95a..06c52c3e909bd 100644 --- a/ext/standard/tests/math/is_nan_basic.phpt +++ b/ext/standard/tests/math/is_nan_basic.phpt @@ -2,20 +2,21 @@ Test is_nan() - basic function test is_nan() --FILE-- ---EXPECT-- +--EXPECTF-- +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(false) bool(false) bool(false) diff --git a/ext/standard/tests/math/pow.phpt b/ext/standard/tests/math/pow.phpt index 4b515ad882daf..dfe4485cacf41 100644 --- a/ext/standard/tests/math/pow.phpt +++ b/ext/standard/tests/math/pow.phpt @@ -143,7 +143,7 @@ var_dump(epsilon_equal( LONG_MAX*LONG_MAX , pow(LONG_MAX,2.0) )); var_dump(epsilon_equal( LONG_MIN*LONG_MIN , pow(LONG_MIN,2.0) )); ?> ---EXPECT-- +--EXPECTF-- 1,1,0,0 bool(true) bool(true) @@ -155,7 +155,11 @@ bool(true) bool(true) bool(true) bool(true) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(true) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(true) bool(true) bool(true) @@ -180,7 +184,11 @@ bool(true) bool(true) bool(true) bool(true) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(true) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(true) bool(true) bool(true) @@ -212,7 +220,11 @@ bool(true) bool(true) bool(true) bool(true) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(true) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(true) bool(true) bool(true) @@ -237,7 +249,11 @@ bool(true) bool(true) bool(true) bool(true) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(true) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d bool(true) bool(true) bool(true) diff --git a/ext/standard/tests/math/pow_divisionbyzero.phpt b/ext/standard/tests/math/pow_divisionbyzero.phpt new file mode 100644 index 0000000000000..0a3eed04107c6 --- /dev/null +++ b/ext/standard/tests/math/pow_divisionbyzero.phpt @@ -0,0 +1,40 @@ +--TEST-- +pow() division by zero error +--FILE-- + +--EXPECTF-- +int(1) +float(1) +float(1) +float(1) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d +float(INF) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d +float(INF) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d +float(INF) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d +float(INF) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d +float(INF) + +Deprecated: Power of base 0 and negative exponent is deprecated in %s on line %d +float(INF)