Commit 769441ba430 for php.net

commit 769441ba430995733d2ad21727d51b1ace115317
Author: Weilin Du <108666168+LamentXU123@users.noreply.github.com>
Date:   Mon May 11 18:52:46 2026 +0800

    ext/gmp: Emit deprecation for precision-losing float RHS in ** / << / >> (#21945)

    This is effectively fixing a missed case of the https://wiki.php.net/rfc/implicit-float-int-deprecate RFC.

diff --git a/NEWS b/NEWS
index 4f8fe29d53e..8974665955f 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,8 @@ PHP                                                                        NEWS
   . gmp_fact() reject values larger than unsigned long. (David Carlier)
   . gmp_pow/binomial/root/rootrem and shift/pow operators reject values
     larger than unsigned long. (David Carlier)
+  . GMP exponentiation and shift operators now emit a deprecation warning
+    when converting a float right operand to int loses precision. (Weilin Du)

 - Hash:
   . Upgrade xxHash to 0.8.2. (timwolla)
diff --git a/UPGRADING b/UPGRADING
index bbf0fc514b6..5837f7ac62f 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -186,6 +186,11 @@ PHP 8.6 UPGRADE NOTES
 4. Deprecated Functionality
 ========================================

+- GMP
+  . The shift (<<, >>) and exponentiation (**) operators on GMP objects now
+    emit a deprecation warning when converting a float right operand to int
+    loses precision.
+
 - Mbstring:
   . Mbregex has been deprecated, because the underlying Oniguruma library
     is no longer maintained.
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index 82f5748fa4c..2a0726b61bc 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -332,11 +332,11 @@ 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()
+			bool failed;
 			switch (Z_TYPE_P(op2)) {
 				case IS_DOUBLE:
-					shift = zval_get_long(op2);
-					if (UNEXPECTED(EG(exception))) {
+					shift = zval_try_get_long(op2, &failed);
+					if (UNEXPECTED(failed)) {
 						return FAILURE;
 					}
 					break;
diff --git a/ext/gmp/tests/overloading_with_float_fractional.phpt b/ext/gmp/tests/overloading_with_float_fractional.phpt
index fc078eeec3e..a86356a9dd5 100644
--- a/ext/gmp/tests/overloading_with_float_fractional.phpt
+++ b/ext/gmp/tests/overloading_with_float_fractional.phpt
@@ -100,6 +100,8 @@
   ["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 @@
   ["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"