[Issue 20360] New: std.variant doesn't do postblit/dtor correctly for large structs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 6 12:00:44 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20360

          Issue ID: 20360
           Summary: std.variant doesn't do postblit/dtor correctly for
                    large structs
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: john.loughran.colvin at gmail.com

unittest
{
    import std.variant;
    static struct S
    {
        int* p;
        ubyte[100] u;

        this(int a)
        {
            p = new int(a);
        }

        this(this)
        {
            p = new int(*p);
        }

        ~this()
        {
            p = null;
        }
    }
    Variant v = S(4);
    assert(v.peek!S.p !is null); // fails
}

--


More information about the Digitalmars-d-bugs mailing list