[Dlang-internal] DIP1000 discussion and testing

Walter Bright via Dlang-internal dlang-internal at puremagic.com
Wed Nov 23 04:18:51 PST 2016


On 11/23/2016 3:05 AM, Mathias Lang wrote:
> [...]

It doesn't actually escape on your version, as main() doesn't return a void*. 
Corrected example:

--------------------
void* abc () @safe
{
     int x;
     void* escape = bar(&x);
     return escape;  // <== correction
}

void* bar (scope void* x) @safe
{
     return fun(&x);  // where the problem lies
}

void* fun (scope void** ptr) @safe
{
     return *ptr;
}
---------------------

Probably the best solution is to not allow taking the address of a scope local. 
Good catch!


More information about the Dlang-internal mailing list