Description
The following code:
<?php
var_dump(array_sum([new GMP("9223372036854775806"), 1]));
Resulted in this output:
float(9.223372036854775E+18)
But I expected this output instead:
This is caused by an erroneous assumption in gmp_cast_object() for _IS_NUMBER casts (as such it can affect other functions as well), namely that ZEND_LONG would be a signed long, but that is not true for LLP64 data models where it is signed long long. On such platforms, values outside of range [INT_MIN, INT_MAX] are converted to float.
PHP Version
PHP-8.2
Operating System
Windows 64bit
Description
The following code:
Resulted in this output:
But I expected this output instead:
This is caused by an erroneous assumption in
gmp_cast_object()for_IS_NUMBERcasts (as such it can affect other functions as well), namely thatZEND_LONGwould be asigned long, but that is not true for LLP64 data models where it issigned long long. On such platforms, values outside of range[INT_MIN, INT_MAX] are converted to float.PHP Version
PHP-8.2
Operating System
Windows 64bit