Bug 4632 – Copy constructor not invoked on array reallocation
Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-12T02:01:00Z
Last change time
2011-07-08T19:26:11Z
Keywords
wrong-code
Assigned to
sean
Creator
rsinfu
Comments
Comment #0 by rsinfu — 2010-08-12T02:01:24Z
Struct copy constructor is not invoked on array copy, expansion nor concatenation; but it should.
-------------------- array_cpctor.d
void main()
{
auto ss = new S[](1);
auto ssdup = ss.dup;
// A copy is created...
assert(&ss[0] != &ssdup[0]);
// but the copy constructor is not invoked!
assert(ssdup[0].copy); // Assertion failure
}
struct S
{
bool copy;
this(this) { copy = true; }
}
--------------------
% dmd -run array_cpctor.d
core.exception.AssertError@array_cpctor(10): Assertion failure
--------------------
Comment #1 by clugdbug — 2011-02-28T14:02:01Z
Might be the same as bug 3475
Comment #2 by yebblies — 2011-07-08T19:26:11Z
*** This issue has been marked as a duplicate of issue 3475 ***