digitalmars.D.bugs - [Issue 22653] New: safe nogc delegate should allocate but doesn't,
- d-bugmail puremagic.com (49/49) Jan 06 2022 https://issues.dlang.org/show_bug.cgi?id=22653
https://issues.dlang.org/show_bug.cgi?id=22653 Issue ID: 22653 Summary: safe nogc delegate should allocate but doesn't, calls member function on dead object Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: iamthewilsonator hotmail.com ``` import std; void main() safe nogc { auto what = exfiltrate(); what(); } auto exfiltrate() safe nogc { S2 s2; s2.temp = &s2.s.foo; return (s2.bar()); } struct S2 { S s; void delegate() safe nogc temp; auto bar() safe nogc { return temp; } } struct S { int i = 42; nogc safe ~this() { i = 0; } void foo() trusted nogc { printf("ok %d", i); } } ``` This should not compile, it does and prints `ok 0`, meaning it got called on a dead object --
Jan 06 2022