Req #80101 [NEW]: Cast to an integer should emit warning if outside the range
| From: | michael dot vorisek at email dot cz | Date: | Mon, 14 Sep 2020 11:30:43 +0000 |
| Subject: | Req #80101 [NEW]: Cast to an integer should emit warning if outside the range | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-228995@lists.php.net to get a copy of this message | ||
From: michael dot vorisek at email dot cz
Operating system: any
PHP version: 7.4.10
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:Cast to an integer should emit warning if outside the range
Description:
------------
if float or string is casted to an integer type and it evaluates to a
number outside the max. range, at least warning should be emitted
Test script:
---------------
var_dump((int) (PHP_INT_MAX + 1)); // int(-9223372036854775808)
var_dump((int) (PHP_INT_MAX + 10)); // int(-9223372036854775808)
var_dump((int) (PHP_INT_MAX + 2000)); // int(-9223372036854773760)
var_dump((int) INF); // int(0)
https://3v4l.org/fgeYU
Expected result:
----------------
all 4 cases must emit at least a warning, similar to 1/0 division
--
Edit bug report at https://bugs.php.net/bug.php?id=80101&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80101&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80101&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80101&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80101&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80101&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80101&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80101&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80101&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80101&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80101&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80101&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80101&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80101&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80101&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80101&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80101&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80101&r=mysqlcfg