Bug 14768 – Error: index 174762 overflow for static array

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-07-03T20:53:00Z
Last change time
2017-07-22T12:35:56Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
deadalnix

Comments

Comment #0 by deadalnix — 2015-07-03T20:53:24Z
This used to compile : enum Items = 174762; uint[32][Items]* items; Now it doesn't with Error : index 174762 overflow for static array This seems to be a regression introduced in 2.067 .
Comment #1 by k.hara.pg — 2015-07-04T05:14:01Z
(In reply to deadalnix from comment #0) > enum Items = 174762; > uint[32][Items]* items; In front-end code, the total size of static array type is limited by 0x1000000, and uint.sizeof * 32 * 174762 = 22369536 = 0x1555500 Therefore the overflow error is not a bug. In fact, the overflow error is raised from 2.060, in windows platform. I'm not sure why it had not been checked in Linux platform, but an overflow check logic refactoring had actually introduced in: https://github.com/D-Programming-Language/dmd/pull/3949 So I guess there was an accepts-invalid bug, and it's fortunately fixed.
Comment #2 by deadalnix — 2015-07-04T06:21:15Z
No, just no. First, this limitation is not in the spec so it is not expected that it is there (especially since it used to work). So it is expected to work (the limit is 16Mb, we are in 2015 we should be able to handle that much memory). And even if we choose that this does not require fixing, the spec needs to be updated, and the error message as well. index 174762 overflow for static array does not mean anything. There is no array access, so how can an overflow occur ?
Comment #3 by ag0aep6g — 2015-07-04T12:18:57Z
(In reply to deadalnix from comment #2) > First, this limitation is not in the spec so it is not expected that it is > there (especially since it used to work). So it is expected to work (the > limit is 16Mb, we are in 2015 we should be able to handle that much memory). > The 16MB limit is in the spec. 174762*32*4 bytes is more than 16MB. > And even if we choose that this does not require fixing, the spec needs to > be updated, and the error message as well. > > index 174762 overflow for static array does not mean anything. There is no > array access, so how can an overflow occur ? I agree that the error message is bad.
Comment #4 by k.hara.pg — 2015-07-04T19:19:36Z
(In reply to ag0aep6g from comment #3) > The 16MB limit is in the spec. 174762*32*4 bytes is more than 16MB. Good catch. From: http://dlang.org/arrays "The total size of a static array cannot exceed 16Mb. A dynamic array should be used instead for such large arrays." > > index 174762 overflow for static array does not mean anything. There is no > > array access, so how can an overflow occur ? > > I agree that the error message is bad. Downgrade to minor diagnostic issue.
Comment #5 by k.hara.pg — 2015-07-04T19:43:13Z
Comment #6 by github-bugzilla — 2015-07-05T05:40:35Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b91401db907f113e5acbf9be4be69b97b286c198 fix Issue 14768 - Error: index 174762 overflow for static array Improve diagnostic message. https://github.com/D-Programming-Language/dmd/commit/64c473c62aa07030f4daf1b76fe04b445f0ebf1f Merge pull request #4798 from 9rnsr/fix14768 Issue 14768 - Error: index 174762 overflow for static array
Comment #7 by github-bugzilla — 2015-10-04T18:19:02Z
Comment #8 by github-bugzilla — 2017-07-22T12:35:56Z
Commits pushed to dmd-cxx at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/b91401db907f113e5acbf9be4be69b97b286c198 fix Issue 14768 - Error: index 174762 overflow for static array https://github.com/dlang/dmd/commit/64c473c62aa07030f4daf1b76fe04b445f0ebf1f Merge pull request #4798 from 9rnsr/fix14768