Bug 20879 – Arrays are oblivious to copy constructors

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-05-29T20:58:37Z
Last change time
2024-03-08T15:19:19Z
Assigned to
No Owner
Creator
Stanislav Blinov
See also
https://issues.dlang.org/show_bug.cgi?id=23557, https://issues.dlang.org/show_bug.cgi?id=23556, https://issues.dlang.org/show_bug.cgi?id=23563, https://issues.dlang.org/show_bug.cgi?id=24432

Comments

Comment #0 by stanislav.blinov — 2020-05-29T20:58:37Z
// 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
Comment #1 by stanislav.blinov — 2020-06-02T15:12:27Z
Going to upgrade this to critical, seeing as the spec recommends switching to copy ctors, whereas neither the compiler nor the runtime are actually ready for such a switch.
Comment #2 by razvan.nitu1305 — 2020-06-17T08:46:24Z
First brick that tackles dup and idup for arrays: https://github.com/dlang/druntime/pull/3139
Comment #3 by ilyayaroshenko — 2020-11-07T09:06:10Z
Comment #4 by razvan.nitu1305 — 2022-04-19T06:10:48Z
Comment #5 by snarwin+bugzilla — 2024-03-08T15:16:12Z
Only half of this issue was fixed. I've resubmitted the other half as issue 24432.