Thread overview
[Issue 14768] Error: index 174762 overflow for static array
Jul 04, 2015
Kenji Hara
Jul 04, 2015
Kenji Hara
Jul 04, 2015
deadalnix
Jul 04, 2015
ag0aep6g@gmail.com
Jul 04, 2015
Kenji Hara
Jul 04, 2015
Kenji Hara
July 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14768

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
(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.

--
July 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14768

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--
July 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14768

deadalnix <deadalnix@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from deadalnix <deadalnix@gmail.com> ---
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 ?

--
July 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14768

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com

--- Comment #3 from ag0aep6g@gmail.com ---
(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.

--
July 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14768

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
           Severity|regression                  |minor

--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> ---
(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.

--
July 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14768

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/4798

--
July 05, 2015
https://issues.dlang.org/show_bug.cgi?id=14768

--- Comment #6 from github-bugzilla@puremagic.com ---
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

--
October 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14768

--- Comment #7 from github-bugzilla@puremagic.com ---
Commits pushed to stable 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

https://github.com/D-Programming-Language/dmd/commit/64c473c62aa07030f4daf1b76fe04b445f0ebf1f Merge pull request #4798 from 9rnsr/fix14768

--
July 22, 2017
https://issues.dlang.org/show_bug.cgi?id=14768

--- Comment #8 from github-bugzilla@puremagic.com ---
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

--