digitalmars.D.bugs - [Issue 14585] New: destructor called on garbage in std.variant
- via Digitalmars-d-bugs (45/45) May 15 2015 https://issues.dlang.org/show_bug.cgi?id=14585
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: nobody puremagic.com Reporter: ag0aep6g gmail.com Originally found by Fyodor Ustinov who posted to digitalmars.D.learn and digitalmars.D: http://forum.dlang.org/post/nobzbhpqsbzutljejifj forum.dlang.org http://forum.dlang.org/post/oqjnjvchzatzkaboeygz forum.dlang.org 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 core.exception.AssertError test4.d(10): Assertion failure ---- --
May 15 2015