[php-src] Issue #19118: Too big `string` to `int` cast results nonsense
| From: | kkmuffme | Date: | Sun, 13 Jul 2025 15:12:03 +0000 |
| Subject: | [php-src] Issue #19118: Too big `string` to `int` cast results nonsense | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250426@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19118
Author: kkmuffme
### Description
The following code:
```php
<?php
if ( (string) PHP_INT_MAX === '9223372036854775808' ) {
echo "string identical" . PHP_EOL;
}
if ( PHP_INT_MAX === (int) '9223372036854775808' ) {
echo "int identical" . PHP_EOL;
}
```
Resulted in this output:
```
int identical
```
But I expected this output instead:
```
Deprecated: Conversion from string '9223372036854775808' to int loses precision
```
A very similar error already exists when converting float to int implicitly e.g.
$a[
PHP_INT_MAX + 1 ] = '';
See also https://github.com/php/php-src/issues/17081
which reports that for float/int casts
### PHP Version
```plain
PHP 8.4.8
```
### Operating System
_No response_