digitalmars.D.bugs - [Issue 18484] New: [dip1000] Subtype allows reference to escape with
- d-bugmail puremagic.com (48/48) Feb 21 2018 https://issues.dlang.org/show_bug.cgi?id=18484
https://issues.dlang.org/show_bug.cgi?id=18484 Issue ID: 18484 Summary: [dip1000] Subtype allows reference to escape with implicit casting Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: radu.racariu gmail.com Compile the following with dmd 2.079-beta1 (older compilers behave the same) and -dip1000: ================================ struct S { property char[] c() return { return i.c; } alias c this; static struct I { char[] c; } I* i; } char[] c() { auto x = S(); return x; } =========================== Produces a nice error: Error: returning x.c() escapes a reference to local variable x Now change 'c' function to this =========================== char[] c() { return S(); } =========================== No error is reported. Expected to see the same error. --
Feb 21 2018