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

RazvanN <[email protected]> changed:

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

--- Comment #5 from RazvanN <[email protected]> ---
Hmmm, there's seems to be a problem with the creation of the second delegate in
the original code (the first delegate is created when virtualFunc() is passed
to the lazy parameter). If the delegate is extracted directly, the context
pointer is preserved correctly:

//@safe:

void delegate() later;

void lazyFun(lazy void expr)
{
    later = &expr;
    //later = { expr; };
}

class C
{
    void virtualFunc() {}

    final void run()
    {
        lazyFun(virtualFunc());
    }   
}

void main()
{
    auto c = new C;
    c.run();
    later();
}

However, the code is not safe anymore.

--

Reply via email to