D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21704 - Nullable fails to destroy static array elements
Summary: Nullable fails to destroy static array elements
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2021-03-12 22:35 UTC by Paul Backus
Modified: 2021-03-13 06:26 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Paul Backus 2021-03-12 22:35:34 UTC
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.
Comment 1 Dlang Bot 2021-03-12 23:15:35 UTC
@pbackus created dlang/phobos pull request #7851 "Fix Issue 21704 - Nullable fails to destroy static array elements" fixing this issue:

- Fix Issue 21704 - Nullable fails to destroy static array elements

https://github.com/dlang/phobos/pull/7851
Comment 2 Dlang Bot 2021-03-13 06:26:03 UTC
dlang/phobos pull request #7851 "Fix Issue 21704 - Nullable fails to destroy static array elements" was merged into master:

- a56cc192bb635d3baa2e5b77976f4cec27169a6a by Paul Backus:
  Fix Issue 21704 - Nullable fails to destroy static array elements

https://github.com/dlang/phobos/pull/7851