August 01, 2015 Re: Static arrays inside struct and class - bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to NX | V Sat, 01 Aug 2015 19:16:16 +0000 NX via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsáno: > On Saturday, 1 August 2015 at 18:47:00 UTC, Daniel Kozak wrote: > > Still same problem, You can`t allocate more then 16M on stack. Use dynamic allocation > > I don't think "new MyStruct" allocates on stack, actually allocating ~16MB on stack will immediatelly crash the program which is not the case with NewExpression. My fault It is not on stack, but still it is a static allocation |
August 01, 2015 Re: Static arrays inside struct and class - bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to NX | V Sat, 01 Aug 2015 19:21:36 +0000 NX via Digitalmars-d-learn <digitalmars-d-learn@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 |
August 01, 2015 Re: Static arrays inside struct and class - bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | On Saturday, 1 August 2015 at 19:33:26 UTC, Daniel Kozak wrote:
> My fault It is not on stack, but still it is a static allocation
I think you're misusing "static allocation" and "static declaration" for each other.
|
August 01, 2015 Re: Static arrays inside struct and class - bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to NX | V Sat, 01 Aug 2015 20:20:14 +0000 NX via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsáno: > On Saturday, 1 August 2015 at 19:33:26 UTC, Daniel Kozak wrote: > > My fault It is not on stack, but still it is a static allocation > > I think you're misusing "static allocation" and "static declaration" for each other. Yep ;-) |
Copyright © 1999-2021 by the D Language Foundation