https://issues.dlang.org/show_bug.cgi?id=24208
--- Comment #1 from Paul Backus ---
Actually, it turns out the second function is not necessary:
---
void main() @safe
{
int* escaped;
void escape(int* p) @safe
{
escaped = p;
}
int n;
escape();
assert(escaped == );
}
---
So, I guess the problem is either that the compiler is incorrectly inferring
`p` as `return scope`, or it's *correctly* inferring `p` as `return scope` but
failing to notice at the calls site that the "return value" has a longer
lifetime than `n`.
If it's the second case, the error should be the same one produced by this
program:
---
void main() @safe
{
int* escaped;
static void escape(ref int* ret, return scope int* p) @safe
{
ret = p;
}
int n;
escape(escaped, );
// Error: address of variable `n` assigned to `escaped`
// with longer lifetime
assert(escaped == );
}
---
--