Supplied range exceeds maximum array size by 0 elements
未关闭
还没有人认领这个 Issue。
Bug
Extension: standard
Status: Verified
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
The following code:
<?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
8.5.7, 8.4.22
Operating System
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在 PHP 8.5.7 或 8.4.22 上复现报告的 range(0, (1 << 30) - 1) 情况,然后跟踪 range() 的实现和最大数组大小的计算。完成标准是:有效的最大大小范围不再引发此错误,并且报告的计算大小会计入元素 0。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, php
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100