Issue ID: 18575
           Summary: making delegate from member function can lead to
                    unsafe code
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd

As reported by Tomer Filiba:


    struct S {
        int x;

        auto foo() {return &bar;}
        void bar() {x = 999;}

    auto f() {
        auto s = S(100);

    void main() {
        auto dg = f();
        dg();     // i now have a delegate that will write 999 to some random
stack location


Reply via email to