[Issue 21704] New: Nullable fails to destroy static array elements

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 12 22:35:34 UTC 2021


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

          Issue ID: 21704
           Summary: Nullable fails to destroy static array elements
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: snarwin+bugzilla at gmail.com

Example program:

---
import std.typecons, std.array;

bool destroyed;

struct Probe
{
    ~this() { destroyed=true; }
}

void main()
{
    {
        Nullable!(Probe[1]) example = staticArray([Probe()]);
        destroyed = false;
    }
    assert(destroyed);
}
---

The `Probe` instance inside `example` should have its destructor called when
`example` goes out of scope. Since it does not, the assertion fails.

--


More information about the Digitalmars-d-bugs mailing list