Bug 21704 – Nullable fails to destroy static array elements
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-12T22:35:34Z
Last change time
2021-03-13T06:26:03Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus
Comments
Comment #0 by snarwin+bugzilla — 2021-03-12T22:35:34Z
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 by dlang-bot — 2021-03-12T23:15:35Z
@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 by dlang-bot — 2021-03-13T06:26:03Z
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