https://issues.dlang.org/show_bug.cgi?id=13902
Issue ID: 13902
Summary: Compiler allows escaping the address of part of a
local
Product: D
Version: D2
Hardware: x86
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
Currently the compiler disallows this:
ref int fun() {
int x;
return x; // escape the address of a local
}
However, this goes unchecked:
struct S {
int x;
}
ref int fun() {
S s;
return s.x; // escape the address of part of a local
}
Direct member access is easy to check using the same logic, so I'm filing this
as a bug. DIP25 addresses more sophisticated detection cases.
--