www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20879] New: Arrays are oblivious to copy constructors

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

          Issue ID: 20879
           Summary: Arrays are oblivious to copy constructors
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: stanislav.blinov gmail.com

// dmd 2.092

struct Simple {
    this(ref scope const Simple) {
        assert(0);
    }
}

unittest {
    auto arr = [ Simple() ];
    auto brr = arr.dup; // no assert
}

struct Complicated {
    int* ptr;

    this (ref scope const Complicated) {
        /* ... */
    }
}

unittest {
    auto arr = [ const(Complicated)() ];
    auto brr = arr.dup; // does not compile (only checks for is(const(U) : T))
}


See also https://issues.dlang.org/show_bug.cgi?id=20365

--
May 29