https://issues.dlang.org/show_bug.cgi?id=14585
Issue ID: 14585
Summary: destructor called on garbage in std.variant
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: Phobos
Assignee: [email protected]
Reporter: [email protected]
Originally found by Fyodor Ustinov who posted to digitalmars.D.learn and
digitalmars.D:
http://forum.dlang.org/post/[email protected]
http://forum.dlang.org/post/[email protected]
Pull request on the way.
----
import std.stdio;
import std.variant: Variant;
struct S
{
int x = 42;
~this()
{
writeln("x: ", x);
assert(x == 42);
}
}
void main()
{
Variant(S()).get!S;
}
----
Output (truncated):
----
x: 42
x: 42
x: 42
x: 7017840
x: 42
[email protected](10): Assertion failure
----
--