[Issue 5667] [GSoC] "clear" does not call destructors on structs embedded in structs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 6 10:47:38 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5667
--- Comment #3 from Cristi Cobzarenco <cristi.cobzarenco at gmail.com> 2011-07-06 10:42:33 PDT ---
I think I found a fix, but I'm not sure if it's correct as I don't know much
about the D runtime. In file object_.d, line 2600:
void clear(T)(ref T obj) if (is(T == struct))
{
- static if (is(typeof(obj.__dtor())))
- {
- obj.__dtor();
- }
+ typeid(T).destroy( &obj );
auto buf = (cast(ubyte*) &obj)[0 .. T.sizeof];
auto init = cast(ubyte[])typeid(T).init();
if(init.ptr is null) // null ptr means initialize to 0s
buf[] = 0;
else
buf[] = init[];
}
This fixes it for me. You need to modifiy import/object.di as well, because
object_.d doesn't get header'd into object.di, for some reason I don't know.
I might make a pull request, but I'm not 100% this is correct, I would like to
get some feedback.
--
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