Bug 3475 – .dup does not call this(this) for elements

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-11-05T10:50:00Z
Last change time
2014-02-14T20:35:35Z
Keywords
wrong-code
Assigned to
nobody
Creator
andrei

Comments

Comment #0 by andrei — 2009-11-05T10:50:17Z
struct Widget { private int[] array; this(uint length) { array = new int[length]; } this(this) { array = array.dup; } } void main() { auto a = new Widget[1]; a[0] = Widget(10); auto b = a.dup; assert(b[0].array !is a[0].array); } The code fails. It should pass.
Comment #1 by clugdbug — 2011-02-28T14:03:02Z
Bug 4632 is probably a duplicate.
Comment #2 by yebblies — 2011-07-08T19:26:00Z
This works on current dmd (2.053)
Comment #3 by yebblies — 2011-07-08T19:26:11Z
*** Issue 4632 has been marked as a duplicate of this issue. ***