www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18913] New: Cannot move static array of non-copyable type

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

          Issue ID: 18913
           Summary: Cannot move static array of non-copyable type
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

This code fails

struct NoCopy
{
    int payload; // some payload
    ~this() { } // destructor to observe moving
 disable:
    this(this); // make it non copyable
}

void f(NoCopy[2]) { }

void main()
{
    import std.algorithm.mutation : move;
    NoCopy[2] ncarray = [ NoCopy(1), NoCopy(2) ];
    static assert(!__traits(compiles,
        f(ncarray) // would copy
    ));
    f(move(ncarray)); // fails
}

move wants to copy content.

This is not a dup of 8067.

--
May 29 2018