Bug 23032 – Static variable of nested type causes runtime crash

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-04-17T19:02:47Z
Last change time
2024-12-13T19:22:19Z
Assigned to
No Owner
Creator
crazymonkyyy
Moved to GitHub: dmd#20090 →

Comments

Comment #0 by crazymonkyyy — 2022-04-17T19:02:47Z
```d import std; struct framelaundering(FRAME){ static FRAME main; ref i(){return main.j;} } void main(){ int i; struct here{ ref j(){return i;} } framelaundering!here foo; foo.i++; i.writeln; } ``` causes a runtime crash; whats happening to the otherwise magic static keyword was extremely unclear to me. Id suggest a warning "here from main.here has a context pointer, when its used in framelaundering!here.main is initialed without it because its static" or sometin
Comment #1 by snarwin+bugzilla — 2022-04-17T20:22:31Z
Simplified example: --- void main() { int i; struct Nested { ref get() { return i; } } static Nested n; n.get()++; // segfault } ---
Comment #2 by robert.schadek — 2024-12-13T19:22:19Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20090 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB