https://issues.dlang.org/show_bug.cgi?id=23445
--- Comment #7 from Walter Bright <bugzi...@digitalmars.com> --- (In reply to timon.gehr from comment #6) > The delegate context is allocated on the heap. There is a `scope int* p` in > that context, and this pointer points to the stack variable `x`. > > `qux` uses `foo` to escape a pointer to the local stack variable `x`. The > delegate context is not even being referenced anymore when the UB happens. > `foo` is just a device that allows `scope`-laundering an arbitrary pointer. > `scope` pointer in, non-`scope` pointer out. You're right. I was mistaken. --