[Issue 5270] Using a scope delegate allows memory corruption in safe mode

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Aug 25 00:07:57 PDT 2016


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

--- Comment #6 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to hsteoh from comment #4)
> Another failing case that illustrates the problem:
> ------
> int delegate() globDg;
> 
> void func(scope int delegate() dg) {
>         globDg = dg; // should be rejected but isn't
>         globDg();
> }

Annotating func() with @safe results in:

  test3.d(4): Error: scope variable dg assigned to non-scope globDg

with Pull Request:

  https://github.com/dlang/dmd/pull/5972

This check is limited to @safe code to avoid breaking too much existing code.

--


More information about the Digitalmars-d-bugs mailing list