[Issue 8538] array variadic apparently doesn't get copied in closure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 28 04:56:22 UTC 2022


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

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #2 from Walter Bright <bugzilla at digitalmars.com> ---
A simpler version of the same problem:

---
@safe
int delegate() test(scope int* p)
{
    return () { return *p; };
}
---

`p` is placed in a dynamically allocated closure, which then escapes via the
returned delegate.

The fix is to not allow scope variables to be put in a dynamic closure.

--


More information about the Digitalmars-d-bugs mailing list