D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14585 - destructor called on garbage in std.variant
Summary: destructor called on garbage in std.variant
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-15 11:41 UTC by ag0aep6g
Modified: 2017-07-19 17:43 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ag0aep6g 2015-05-15 11:41:34 UTC
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
----
Comment 1 github-bugzilla 2015-05-17 01:22:10 UTC
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
Comment 2 github-bugzilla 2017-07-19 17:43:21 UTC
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