[Issue 23445] Can leak scope variable through delegate context

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 1 20:41:08 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23445

--- Comment #7 from Walter Bright <bugzilla at 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.

--


More information about the Digitalmars-d-bugs mailing list