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: nob...@puremagic.com Reporter: c...@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. --