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; } ---
Comment #2 by sludwig — 2013-10-08T08:29:20Z
Comment #3 by github-bugzilla — 2013-10-09T08:18:47Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/5aac4a007adff938e5326675a039489c77c74ee6 fix issue 11194 - std.container.Array.reserve calls opAssign on uninitialized data https://github.com/D-Programming-Language/phobos/commit/4b024858a81e607214c96dc10a024d25f4af5798 Merge pull request #1620 from s-ludwig/fix_11194 fix issue 11194 - std.container.Array.reserve calls opAssign on uninitia...