From 1de84975cf3632b894722d97ff41190de5ace66d Mon Sep 17 00:00:00 2001 From: lamentxu <1372449351@qq.com> Date: Sun, 3 May 2026 00:48:59 +0800 Subject: [PATCH 1/5] init --- NEWS | 4 ++++ UPGRADING | 5 +++++ ext/gmp/gmp.c | 9 +++++---- ext/gmp/tests/overloading_with_float_fractional.phpt | 6 ++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 3dbfb2724956..5cd7d8cafdc9 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.4.22 +- GMP: + . GMP exponentiation and shift operators now emit a deprecation warning + when converting a float right operand to int loses precision. (Weilin Du) + - Opcache: . Fixed tracing JIT crash when a VM interrupt is handled during an observed user function call. (Levi Morrison) diff --git a/UPGRADING b/UPGRADING index a67fc1b1d88f..14405449c660 100644 --- a/UPGRADING +++ b/UPGRADING @@ -522,6 +522,11 @@ PHP 8.4 UPGRADE NOTES deprecated. Use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead. +- GMP: + . The shift (<<, >>) and exponentiation (**) operators on GMP objects now + emit a deprecation warning when converting a float right operand to int + loses precision. + - LDAP: . Calling ldap_connect() with more than 2 arguments is deprecated. Use ldap_connect_wallet() instead. diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 420497d2693e..8f9640d9ddf2 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -347,14 +347,15 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { if (UNEXPECTED(!IS_GMP(op2))) { - // For PHP 8.3 and up use zend_try_get_long() switch (Z_TYPE_P(op2)) { - case IS_DOUBLE: - shift = zval_get_long(op2); - if (UNEXPECTED(EG(exception))) { + case IS_DOUBLE: { + bool failed; + shift = zval_try_get_long(op2, &failed); + if (UNEXPECTED(failed)) { return FAILURE; } break; + } case IS_STRING: if (is_numeric_str_function(Z_STR_P(op2), &shift, NULL) != IS_LONG) { goto valueof_op_failure; diff --git a/ext/gmp/tests/overloading_with_float_fractional.phpt b/ext/gmp/tests/overloading_with_float_fractional.phpt index fc078eeec3e9..a86356a9dd54 100644 --- a/ext/gmp/tests/overloading_with_float_fractional.phpt +++ b/ext/gmp/tests/overloading_with_float_fractional.phpt @@ -100,6 +100,8 @@ object(GMP)#2 (1) { ["num"]=> string(1) "0" } + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(69) "150130937545296572356771972164254457814047970568738777235893533016064" @@ -122,10 +124,14 @@ object(GMP)#2 (1) { ["num"]=> string(1) "0" } + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(15) "184717953466368" } + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(1) "0" From f2fc4fc1f4cf81f67e8d22aab4d67b641966f0fe Mon Sep 17 00:00:00 2001 From: lamentxu <1372449351@qq.com> Date: Sun, 3 May 2026 00:48:59 +0800 Subject: [PATCH 2/5] init --- NEWS | 4 ++++ UPGRADING | 5 +++++ ext/gmp/gmp.c | 8 ++++---- ext/gmp/tests/overloading_with_float_fractional.phpt | 6 ++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 3dbfb2724956..5cd7d8cafdc9 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.4.22 +- GMP: + . GMP exponentiation and shift operators now emit a deprecation warning + when converting a float right operand to int loses precision. (Weilin Du) + - Opcache: . Fixed tracing JIT crash when a VM interrupt is handled during an observed user function call. (Levi Morrison) diff --git a/UPGRADING b/UPGRADING index a67fc1b1d88f..14405449c660 100644 --- a/UPGRADING +++ b/UPGRADING @@ -522,6 +522,11 @@ PHP 8.4 UPGRADE NOTES deprecated. Use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead. +- GMP: + . The shift (<<, >>) and exponentiation (**) operators on GMP objects now + emit a deprecation warning when converting a float right operand to int + loses precision. + - LDAP: . Calling ldap_connect() with more than 2 arguments is deprecated. Use ldap_connect_wallet() instead. diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 420497d2693e..46285a496991 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -347,14 +347,14 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { if (UNEXPECTED(!IS_GMP(op2))) { - // For PHP 8.3 and up use zend_try_get_long() switch (Z_TYPE_P(op2)) { case IS_DOUBLE: - shift = zval_get_long(op2); - if (UNEXPECTED(EG(exception))) { + bool failed; + shift = zval_try_get_long(op2, &failed); + if (UNEXPECTED(failed)) { return FAILURE; - } break; + } case IS_STRING: if (is_numeric_str_function(Z_STR_P(op2), &shift, NULL) != IS_LONG) { goto valueof_op_failure; diff --git a/ext/gmp/tests/overloading_with_float_fractional.phpt b/ext/gmp/tests/overloading_with_float_fractional.phpt index fc078eeec3e9..a86356a9dd54 100644 --- a/ext/gmp/tests/overloading_with_float_fractional.phpt +++ b/ext/gmp/tests/overloading_with_float_fractional.phpt @@ -100,6 +100,8 @@ object(GMP)#2 (1) { ["num"]=> string(1) "0" } + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(69) "150130937545296572356771972164254457814047970568738777235893533016064" @@ -122,10 +124,14 @@ object(GMP)#2 (1) { ["num"]=> string(1) "0" } + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(15) "184717953466368" } + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d object(GMP)#2 (1) { ["num"]=> string(1) "0" From 3194cc433ea31b51c93d17b21f4e5edae6b2fe19 Mon Sep 17 00:00:00 2001 From: lamentxu <1372449351@qq.com> Date: Sun, 3 May 2026 00:57:59 +0800 Subject: [PATCH 3/5] fix blankets --- ext/gmp/gmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 46285a496991..4e42e43ac30a 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -353,8 +353,8 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val shift = zval_try_get_long(op2, &failed); if (UNEXPECTED(failed)) { return FAILURE; + } break; - } case IS_STRING: if (is_numeric_str_function(Z_STR_P(op2), &shift, NULL) != IS_LONG) { goto valueof_op_failure; From 52a14b366183ad17df497e112b5ab901c0391aab Mon Sep 17 00:00:00 2001 From: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Date: Sun, 3 May 2026 09:57:36 +0800 Subject: [PATCH 4/5] fix UPGRADING --- UPGRADING | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/UPGRADING b/UPGRADING index 14405449c660..6761b2e77496 100644 --- a/UPGRADING +++ b/UPGRADING @@ -81,6 +81,10 @@ PHP 8.4 UPGRADE NOTES . Gettext: . bind_textdomain_codeset, textdomain and d(*)gettext functions now throw an exception if the domain argument is empty. + . GMP: + . The shift (<<, >>) and exponentiation (**) operators on GMP objects now + emit a deprecation warning when converting a float right operand to int + loses precision. . Intl: . resourcebundle_get(), ResourceBundle::get(), and accessing offsets on a ResourceBundle object now throw: @@ -522,11 +526,6 @@ PHP 8.4 UPGRADE NOTES deprecated. Use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead. -- GMP: - . The shift (<<, >>) and exponentiation (**) operators on GMP objects now - emit a deprecation warning when converting a float right operand to int - loses precision. - - LDAP: . Calling ldap_connect() with more than 2 arguments is deprecated. Use ldap_connect_wallet() instead. From 9ae23e6d669d36d4ed82f626fc965dfca2dbbf81 Mon Sep 17 00:00:00 2001 From: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Date: Sun, 3 May 2026 10:02:02 +0800 Subject: [PATCH 5/5] Fix CI to adopt in C23... --- ext/gmp/gmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 4e42e43ac30a..dd1aed03d9d4 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -347,9 +347,9 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { if (UNEXPECTED(!IS_GMP(op2))) { + bool failed; switch (Z_TYPE_P(op2)) { case IS_DOUBLE: - bool failed; shift = zval_try_get_long(op2, &failed); if (UNEXPECTED(failed)) { return FAILURE;