[Issue 18088] wrong lifetime evaluation of pointers or this-pointers in a struct with @safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 16 19:17:10 UTC 2017


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

--- Comment #2 from Johannes Nordhoff <mephisto at nordhoff-online.de> ---
I gave a bad example. 


file: app2.d
~~~~~~~~~~~~~~~~~~~~~

void main() {
    A a = A( true);
}

@safe

struct A {
    bool delegate() lala;

    this( bool i) {
        lala = &aFunc;
    }

    bool aFunc() {
        return true;
    }
}

~~~~~~~~~~~~~~~~~~~~~


$
$ dmd app2.d
app2.d(12): Error: address of variable this assigned to this with longer
lifetime
$


so, I thought the pointer to a function shouldnt change when copying the
struct.

--


More information about the Digitalmars-d-bugs mailing list