Issue 20360 - std.variant doesn't do postblit/dtor correctly for large structs
Summary: std.variant doesn't do postblit/dtor correctly for large structs
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: industry
Depends on:
Blocks:
 
Reported: 2019-11-06 12:00 UTC by John Colvin
Modified: 2024-12-01 16:35 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description John Colvin 2019-11-06 12:00:44 UTC
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
}
Comment 1 John Colvin 2019-11-06 12:02:42 UTC
related to https://issues.dlang.org/show_bug.cgi?id=12944
Comment 2 berni44 2020-01-05 19:06:57 UTC
On my computer the static array u can contain up to 24 element to work. Together with the 8 bytes of the pointer this looks like 32 bytes is the magic border.
Comment 3 dlangBugzillaToGithub 2024-12-01 16:35:58 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9783

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB