Static arrays inside struct and class - bug?
Daniel Kozak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Aug 1 12:47:45 PDT 2015
V Sat, 01 Aug 2015 19:21:36 +0000
NX via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> napsáno:
> On Saturday, 1 August 2015 at 18:50:09 UTC, Daniel Kozak wrote:
> > No you don't. You still use static allocation for array
>
> Can clarify why does that happen and I still suspect it's a
> static allocation it would increase output exe if it was really
> that static..?
No it would not increase output exe. Problem is with definition:
type[size] val; // static declaration so compilere check max 16M.
But you are right, in your case it could be improved and such
declaration could work.
because:
S {
byte[16*1024*1024*1024] arr;
}
void main() {
auto s = new S();
if (s is null) {
// error cannont allocate enought memory
}
}
but:
void main() {
byte[16*1024*1024*1024] arr; // impossible to check if is allocated
}
Maybe you can open an enhancment on issues.dlang.org
More information about the Digitalmars-d-learn
mailing list