digitalmars.D.bugs - [Issue 23099] New: DMD generates dangerous code on array literals
- d-bugmail puremagic.com (31/31) May 09 2022 https://issues.dlang.org/show_bug.cgi?id=23099
https://issues.dlang.org/show_bug.cgi?id=23099 Issue ID: 23099 Summary: DMD generates dangerous code on array literals usage inside functions Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: contact lsferreira.net Currently, DMD clutters the stack when a non-constant literal is used but never modified. For huge literal arrays, this ends up with a stack overflow. The solution here would be to allocate space on the read-only section and point to that when used. --- import core.stdc.stdio; struct S { int[10000000] _; } int main() nogc { foreach(f; [S()]) printf("%d\n", f._[0]); return 0; } --
May 09 2022