[Issue 15191] New: DIP25: Taking address of ref return is not type checked soundly
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Oct 12 03:08:40 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15191
Issue ID: 15191
Summary: DIP25: Taking address of ref return is not type
checked soundly
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: timon.gehr at gmx.ch
The following code corrupts memory:
enum N=100;
ref int[N] foo(return ref int[N] s)@safe{ return s; }
int[N]* bar(return ref int[N] s)@safe{ return &foo(s); }
ref int[N] baz()@safe{ int[N] s; return *bar(s); }
void bang(ref int[N] x)@safe{ x[]=0x25BAD; }
void main()@safe{ bang(baz()); }
--
More information about the Digitalmars-d-bugs
mailing list