[Issue 23561] New: std.typecons.Unique!struct does not destroy struct instance
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu Dec 15 19:29:46 UTC 2022
    
    
  
https://issues.dlang.org/show_bug.cgi?id=23561
          Issue ID: 23561
           Summary: std.typecons.Unique!struct does not destroy struct
                    instance
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: nick at geany.org
void main()
{
    import std.typecons;
    int i;
    struct S
    {
        ~this() { i++; }
    }
    {
        Unique!S u = new S;
    }
    assert(i == 1); // fails
}
Unique.~this calls destroy on the S*, not the struct instance:
        if (_p !is null)
        {
            destroy(_p);
            _p = null;
        }
--
    
    
More information about the Digitalmars-d-bugs
mailing list