← Back to index
|
Original Bugzilla link
Bug 19393 – Structure dtor isn't called after passed to T[]... argument. Memory leaks issue
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-11-12T14:05:59Z
Last change time
2018-11-25T10:25:37Z
Keywords
industry
Assigned to
RazvanN
Creator
Илья Ярошенко
Comments
Comment #0
by ilyayaroshenko — 2018-11-12T14:05:59Z
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.
Comment #1
by razvan.nitu1305 — 2018-11-13T16:11:22Z
PR:
https://github.com/dlang/dmd/pull/8951
Comment #2
by github-bugzilla — 2018-11-25T10:25:31Z
Commits pushed to master at
https://github.com/dlang/dmd
https://github.com/dlang/dmd/commit/56e1d682f30a9017fbc6d455830f56bbd66d1fb4
Fix Issue 19393 - Structure dtor isn't called after passed to T[]... argument. Memory leaks issue
https://github.com/dlang/dmd/commit/0a43247d4af1f24d37040ee38aa53c119c811653
Merge pull request #8951 from RazvanN7/Issue_19393 Fix Issue 19393 - Structure dtor isn't called after passed to T[] argument. Memory leaks issue