DIP74: Reference Counted Class Objects

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 26 23:35:55 PST 2015


On 2/26/2015 5:37 PM, H. S. Teoh via Digitalmars-d wrote:
> Wait, are you saying that forgetting the 'return' annotation will still
> compile without any warning?? Wow, that's ... not nice. :-(

Indeed, and the compiler will error out if you try that:

---
struct S {
     int x;
}

ref int foo(ref S s) {
     return s.x;
}
---

dmd -c foo -dip25
foo.d(7): Error: escaping reference to local ref variable s

There'd be no point to DIP25 if it didn't.


More information about the Digitalmars-d mailing list