[Issue 16056] immutable delegate can mutate through context pointer

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun May 22 02:24:12 PDT 2016


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

ag0aep6g at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |ag0aep6g at gmail.com
          Component|dlang.org                   |dmd
            Summary|[The D Bug Tracker]         |immutable delegate can
                   |                            |mutate through context
                   |                            |pointer
           Severity|enhancement                 |normal

--- Comment #1 from ag0aep6g at gmail.com ---
The struct doesn't really matter here, as far as I see. Simplified code:

----
import std.stdio;

pure void pure_func(immutable void delegate() pure f)
{
    f();
}

void main() {
    int y;
    writeln("Before: ", y);
    pure_func({ y++; });
    writeln("After: ", y);
}
----

Possibly a duplicate of issue 11043 or issue 1983.

--


More information about the Digitalmars-d-bugs mailing list