[Issue 19393] New: Structure dtor isn't called after passed to T[]... argument. Memory leaks issue
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 12 14:05:59 UTC 2018
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 at puremagic.com
Reporter: ilyayaroshenko at 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.
--
More information about the Digitalmars-d-bugs
mailing list