[Issue 20879] New: Arrays are oblivious to copy constructors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 29 20:58:37 UTC 2020


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 at puremagic.com
          Reporter: stanislav.blinov at 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

--


More information about the Digitalmars-d-bugs mailing list