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

          Issue ID: 19559
           Summary: Unsound escape analysis of struct members
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: yshu...@gmail.com

This code shouldn't compile.

@safe void bad(int *p) {
    struct A {
        int z;
        @safe void badbad(int *p) { p = &z; }
    }
    A badstuff;
    badstuff.badbad(p);
}

@safe void main() {
    int *p = null;
    bad(p);
    *p = 10; // <- boom
}


https://d.godbolt.org/z/xXxecF

--

Reply via email to