https://issues.dlang.org/show_bug.cgi?id=19097

Mike Franklin <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #2 from Mike Franklin <[email protected]> ---
Trying to dissect Walter's back-of-the-napkin description:

Example 1
---------
@safe:

int* frank(return scope int* p) { return p; }

void main()
{
    // lifetimes end in reverse order from which they are declared
    int* p;  // `p`'s lifetime is longer than `i`'s
    int i;   // `i`'s lifetime is longer than `q`'s
    int* q;  // `q`'s lifetime is the shortest

    q = frank(&i); // ok because `i`'s lifetime is longer than `q`'s
    p = frank(&i); // error because `i`'s lifetime is shorter than `p`'s
}

This works in the compiler today if both functions are declared @safe and if
compiled with -dip1000:  https://run.dlang.io/is/CZ3YuU

--

Reply via email to