[Issue 17456] [REG2.075a] spurious lifetime diagnostic on delegates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue May 30 11:06:02 PDT 2017


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

--- Comment #1 from b2.temp at gmx.com ---
(In reply to b2.temp from comment #0)
> repro:
> 
> 
> ===
> struct Foo
> {
>     private void delegate() dg;
>     void assign() @safe {dg = &sameThis;}
>     void sameThis(){}
> }
> ===
> 
> yield: "address of variable this assigned to this with longer lifetime"
> 
> But the delegate is never escaped and the context pointer and the this have
> the same lifetime.

In the project, the equivalent of "sameThis" is @trusted, in case of another
error would appear.

--


More information about the Digitalmars-d-bugs mailing list