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

          Issue ID: 15315
           Summary: can break immutable with std.algorithm.move
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: [email protected]
          Reporter: [email protected]

Shown by Mike Parker in D.learn:
http://forum.dlang.org/post/[email protected]

----
static struct ku
{
    immutable int id;
    ~this() @safe {}
}
void main() @safe
{
    ku k1 = ku(1);
    scope(exit) assert(k1.id == 1); /* fails */
    ku k2 = ku(2);
    scope(exit) assert(k2.id == 2); /* fails too, because there's a destructor
*/
    import std.algorithm: move;
    move(k2, k1);
}
----

--

Reply via email to