Bug 14859 – static declared array with more than 16MB size should be allowed in struct and class declaration

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-08-01T22:08:42Z
Last change time
2020-03-21T03:56:37Z
Assigned to
No Owner
Creator
Ahmet Sait

Comments

Comment #0 by nightmarex1337 — 2015-08-01T22:08:42Z
import std.stdio; struct Stuff { double someData, otherData; wchar[120] someFilePath; // byte[1024*1024*16] hugeArray; // Error: index 16777216 overflow for static array byte[1024*1024*8] hugeArrayPart_1; // dirty hack byte[1024*1024*8] hugeArrayPart_2; SomeOtherComplexStruct theComplexStruct; } int main(string[] argv) { Stuff* st = new Stuff(); writeln((*st).sizeof); readln(); return 0; } 16MB or more sized types should be allowed in order to make above code work without using dirty hacks "global static sized arrays" and "static sized arrays inside static class/struct" more than 16MB size should still not compile (or maybe a warning is better?) they just blow up output size and also heard optlink cause problems but don't know if it's relevant to above code.
Comment #1 by b2.temp — 2015-09-11T10:52:57Z
the OPTLINK restriction (https://issues.dlang.org/show_bug.cgi?id=1542) applies also here even if it looks like the limit value has changed since 2008. for example compile this: --- struct Stuff { byte[1024*1024*8] hugeArrayPart_1; byte[1024*1024*8] hugeArrayPart_2; byte[1024*1024*8] hugeArrayPart_3; byte[1024*1024*8] hugeArrayPart_4; byte[1024*1024*8] hugeArrayPart_5; byte[1024*1024*8] hugeArrayPart_6; } void main(){} --- and you reach the OPTLINK limit.
Comment #2 by bugzilla — 2017-01-30T06:11:03Z
Comment #3 by github-bugzilla — 2017-02-11T09:28:45Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/07855a2f94e216b65a342dc06a7d6f1d6bcafb8f reboot #6081: Fix issue 14859 - 16MiB size limit for static array https://github.com/dlang/dmd/commit/14ba1f62e7f1be6668feddd14d20de4837875585 Merge pull request #6503 from WalterBright/fix14859 reboot #6081: Fix issue 14859 - 16MiB size limit for static array
Comment #4 by github-bugzilla — 2017-02-24T20:34:36Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/07855a2f94e216b65a342dc06a7d6f1d6bcafb8f reboot #6081: Fix issue 14859 - 16MiB size limit for static array https://github.com/dlang/dmd/commit/14ba1f62e7f1be6668feddd14d20de4837875585 Merge pull request #6503 from WalterBright/fix14859