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.