www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22991] New: GC array literals restricted in size

https://issues.dlang.org/show_bug.cgi?id=22991

          Issue ID: 22991
           Summary: GC array literals restricted in size
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kinke gmx.net

This segfaults at runtime with DMD v2.099.0 on Linux:

```
struct S {
    void[32 * 1_048_576] bla;
}

public S* deserializeFull(int i) {
    return &[ getS(i) ][0];
}

S getS(int i) {
    if (i != 0)
        throw new Exception("blub");
    return S();
}

void main(string[] args) {
    deserializeFull(cast(int) args.length);
}
```

Works fine with LDC.

DMD's glue layer apparently creates the literal as a static array on the stack,
before moving it to the GC allocation. This came up in
https://github.com/dlang/dmd/pull/13951.

--
Apr 05 2022