Bug 10194 – std.variant.Variant doesn't call the dtor of struct values
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-28T07:50:25Z
Last change time
2017-08-26T17:24:00Z
Assigned to
No Owner
Creator
Martin Nowak
Comments
Comment #0 by code — 2013-05-28T07:50:25Z
Failing test case
----
import std.variant;
unittest
{
static struct S
{
~this()
{
++cnt;
}
static size_t cnt;
}
Variant v;
// assigning a new value should destroy the existing one
{
v = S();
immutable n = S.cnt;
v = 0;
assert(S.cnt == n + 1);
}
// destroying the variant should destroy it's current value
{
v = S();
immutable n = S.cnt;
destroy(v);
assert(S.cnt == n + 1);
}
}
Comment #1 by yuriy.glukhov — 2014-05-06T10:10:14Z