www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19559] New: Unsound escape analysis of struct members

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: nobody puremagic.com
          Reporter: yshuiv7 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

--
Jan 08 2019