[Issue 2590] New: Deallocator is not called if constructor fails.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jan 17 04:50:24 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2590
Summary: Deallocator is not called if constructor fails.
Product: D
Version: 2.023
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: samukha at voliacable.com
The following test case leaks memory:
import std.c.stdlib;
class C
{
new(size_t size)
{
writefln("In new");
return malloc(size);
}
this()
{
writefln("In constructor");
throw new Exception("Exception in ctor");
}
~this()
{
writefln("in destructor");
}
delete(void* p)
{
writefln("In delete");
free(p);
}
}
void main()
{
try
{
auto c = new C;
}
catch {}
}
----
In new
In constructor
Deallocator should be called to free the memory.
--
More information about the Digitalmars-d-bugs
mailing list