[php-src] Issue #22505: Supplied range exceeds maximum array size by 0 elements

From: Date: Sun, 28 Jun 2026 21:37:50 +0000
Subject: [php-src] Issue #22505: Supplied range exceeds maximum array size by 0 elements
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252301@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/22505 Author: DanielEScherzer ### Description The following code: ```php <?php $max = (1 << 30) - 1; $range = range(0, $max); ``` Resulted in this output: ``` Fatal error: Uncaught ValueError: The supplied range exceeds the maximum array size by 0 elements: start=0, end=1073741823, step=1. Calculated size: 1073741823. Maximum size: 1073741824. in /in/GPBdM:4 Stack trace: #0 /in/GPBdM(4): range(0, 1073741823) #1 {main} thrown in /in/GPBdM on line 4 Process exited with code 255. ``` But I expected this output instead: ``` No error (also the calculated size is wrong, doesn't account for element 0) ``` ### PHP Version ```plain 8.5.7, 8.4.22 ``` ### Operating System _No response_

« previous php.bugs (#252301) next »