[Issue 23561] std.typecons.Unique!struct does not destroy struct instance
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 16 04:48:04 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23561
Vital <vital.fadeev at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vital.fadeev at gmail.com
OS|Linux |Windows
--- Comment #1 from Vital <vital.fadeev at gmail.com> ---
import std.stdio;
static int i;
struct S
{
~this() {
i++;
writeln("DTOR: i == ", i );
}
}
void main()
{
{
auto u = new S;
u.destroy();
// (*u).destroy(); // works fine!
}
import core.memory;
GC.collect();
writeln("EXIT: i == ", i ); // 0, but except 1
assert(i == 1); // fails
}
// Output:
// EXIT: i == 0
// DTOR: i == 1
//
// core.exception.AssertError at source\app.d(24): Assertion failure
Confirm. Also failed.
FAIL: Destructor S, possible not called.
WANTED: Wanted to call S.~this().
PURPOSE: smart-pointer. std.typecons.Unique!S for auto close handle.
DMD: DMD32 D Compiler v2.101.0-dirty, Windows 10, x64
DMD: LDC 1.30, Windows 10, x64
--
More information about the Digitalmars-d-bugs
mailing list