www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15192] New: DIP25: Nested ref returns are type checked

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

          Issue ID: 15192
           Summary: DIP25: Nested ref returns are type checked unsoundly
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timon.gehr gmx.ch

The following code corrupts memory:

enum N=100;
ref int[N] fun(ref int[N] x) safe{
    ref int[N] bar(){ return x; }
    return bar();
}
ref int[N] hun() safe{
    int[N] k;
    return fun(k);
}

void bang(ref int[N] x) safe{ x[]=0x25BAD; }
void main() safe{ bang(hun); }

--
Oct 12 2015