https://issues.dlang.org/show_bug.cgi?id=20809
--- Comment #3 from [email protected] --- Here, let me do it for you: ------ import std.stdio; @safe: struct S { @safe: int a; ~this() { a = 0; } ref val() { return a; } } S bar() { return S(2); } int foo() { return bar.val; // The return value of val is saved locally as ref int and then the destructor of S is called (set the local cache to 0). Now the ref value is dereferenced and returned } void main() { assert(foo() == 2); // foo() is 0 } ------ Just please keep in mind next time to post the entire body of code in the bug so that it will never get lost in the future. --
