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 ----
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/15712f6e6ccc68f86142d75d5f659ca746e8fabe fix issue 14585 - destructor called on garbage in std.variant https://github.com/D-Programming-Language/phobos/commit/4e0347a59c0260f78d1c1ea4ee1a81bc89c93570 Merge pull request #3284 from aG0aep6G/variant fix std.variant issues 14585 and 14586
Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/15712f6e6ccc68f86142d75d5f659ca746e8fabe fix issue 14585 - destructor called on garbage in std.variant https://github.com/dlang/phobos/commit/4e0347a59c0260f78d1c1ea4ee1a81bc89c93570 Merge pull request #3284 from aG0aep6G/variant