[Issue 5353] clear function is calling the destructor twice
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Dec 14 16:37:47 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5353
Simen Kjaeraas <simen.kjaras at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |simen.kjaras at gmail.com
--- Comment #3 from Simen Kjaeraas <simen.kjaras at gmail.com> 2010-12-14 16:35:59 PST ---
Highly interesting: copying the clear function of object_.d in druntime to my
own module, the destructor is called but once.
void myclear(T)(ref T obj) if (is(T == struct))
{
static if (is(typeof(obj.__dtor())))
{
obj.__dtor();
}
auto buf = (cast(void*) &obj)[0 .. T.sizeof];
auto init = (cast(void*) &T.init)[0 .. T.sizeof];
buf[] = init[];
}
struct test {
~this( ) {
writeln( "dtor!" );
}
}
void main( ) {
test* p = new test;
clear( *p );
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list