[Issue 15044] New: [Reg 2.068.0] destroy might leak memory
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Sep 11 14:53:18 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15044
Issue ID: 15044
Summary: [Reg 2.068.0] destroy might leak memory
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: code at dawg.eu
cat > bug.d << CODE
struct Vector
{
~this()
{
}
RefCounted!Vector dup()
{
return RefCounted!Vector(&this);
}
}
struct RefCounted(T)
{
~this()
{
.destroy(*t); // __xdtor of Vector not yet available
static assert(__traits(hasMember, T, "__xdtor"));
}
T* t;
}
CODE
dmd -c bug
----
bug.d(18): Error: static assert (__traits(hasMember, Vector, "__xdtor")) is
false
bug.d(7): instantiated from here: RefCounted!(Vector)
----
The problem is that __xdtor is not yet available when the destructor of
RefCounted is analyzed, hence .destroy won't call the destructor of Vector.
It seems that the creation of __xdtor should happen earlier.
--
More information about the Digitalmars-d-bugs
mailing list