[Issue 15195] New: DIP25: Member functions can leak local variables
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Oct 12 06:34:26 PDT 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 at puremagic.com
Reporter: timon.gehr at 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.)
--
More information about the Digitalmars-d-bugs
mailing list