Req #80101 [Opn]: Cast to an integer should emit warning if outside the range

From: Date: Fri, 05 Nov 2021 18:56:55 +0000
Subject: Req #80101 [Opn]: Cast to an integer should emit warning if outside the range
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237569@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80101&edit=1 ID: 80101 Updated by: cmb@php.net Reported by: michael dot vorisek at email dot cz Summary: Cast to an integer should emit warning if outside the range Status: Open Type: Feature/Change Request Package: *General Issues Operating System: any PHP Version: 7.4.10 Block user comment: N Private report: N New Comment: I'd rather have bigints (<https://wiki.php.net/rfc/bigint>). Previous Comments: ------------------------------------------------------------------------ [2020-09-14 11:30:43] michael dot vorisek at email dot cz 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 this bug report at https://bugs.php.net/bug.php?id=80101&edit=1

« previous php.bugs (#237569) next »