October 12, 2015
https://issues.dlang.org/show_bug.cgi?id=15195

          Issue ID: 15195
           Summary: DIP25: Member functions can leak local variables
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: timon.gehr@gmx.ch

The following code leaks a reference to a local variable:

ref int foo()@safe{
    int x;
    struct S{
        ref int bar(){ return x; }
    }
    S s;
    return s.bar();
}

It is not enough to require 'return' on member functions if the returned reference is not guaranteed to outlive the 'this' pointer.

(This is closely related to issue 15192.)

--