www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10194] New: std.variant.Variant doesn't call the dtor of struct values

http://d.puremagic.com/issues/show_bug.cgi?id=10194

           Summary: std.variant.Variant doesn't call the dtor of struct
                    values
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: code dawg.eu



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);
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 28 2013