https://issues.dlang.org/show_bug.cgi?id=15832
--- Comment #2 from Atila Neves <[email protected]> --- You're right, it's not a bug. I should probably not file things late at night when I can't think anymore. The ref thing should've been obvious. However, even with ref, the explanation isn't quite right: the delegate created in the constructor doesn't reference garbage - the GC should keep the memory alive. It just references the old slice. The issue is that the delegate references a slice that gets copied when `mock` exits. It's fine as long as the pointer in the copied slice gets reallocated, but that's exactly what I was doing. I guess I was also surprised (because of C++) that the Mock struct got copied at all. I'm so used to RVO I don't think about it anymore. --
