digitalmars.D.bugs - [Issue 19393] New: Structure dtor isn't called after passed to
- d-bugmail puremagic.com (48/48) Nov 12 2018 https://issues.dlang.org/show_bug.cgi?id=19393
https://issues.dlang.org/show_bug.cgi?id=19393 Issue ID: 19393 Summary: Structure dtor isn't called after passed to T[]... argument. Memory leaks issue Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: ilyayaroshenko gmail.com import std.stdio; struct S { void* ptr; int counter = 1; ~this() nogc { debug writeln(--counter, ", destructor"); } this(this) nogc { debug writeln(++counter, ", postblit"); } } void foo(const(S)[] ar...) nogc { auto d = ar[0]; } void bar() nogc { foo(S(null)); } void main() { bar(); } --------- output: 2, postblit 1, destructor --------- expected output: 2, postblit 1, destructor 0, destructor The final, second, destructor is never called. This can cause memory leaks. --
Nov 12 2018