Bug 11194 – std.container.Array.reserve calls opAssign on uninitialized data
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-08T04:54:00Z
Last change time
2013-10-11T05:50:57Z
Keywords
pull
Assigned to
nobody
Creator
sludwig
Comments
Comment #0 by sludwig — 2013-10-08T04:54:44Z
The following test case fails:
---
import std.container;
struct S {
int i = 1337;
void opAssign(S other)
{
assert(i == 1337);
}
}
void main()
{
Array!S arr;
arr ~= S.init;
}
---
The same applies for "~this() { assert(i == 1337); }" instead of defining opAssign.
Comment #1 by sludwig — 2013-10-08T08:18:55Z
Git HEAD requires a slightly extended test case:
---
import std.container;
struct S {
int i = 1337;
void* p;
this(this) { assert(i == 1337); }
~this() { assert(i == 1337); }
}
void main()
{
Array!S arr;
S s;
arr ~= s;
arr ~= s;
}
---