[Issue 19559] New: Unsound escape analysis of struct members
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Tue Jan  8 21:41:52 UTC 2019
    
    
  
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 at puremagic.com
          Reporter: yshuiv7 at 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
--
    
    
More information about the Digitalmars-d-bugs
mailing list