http://d.puremagic.com/issues/show_bug.cgi?id=6998



--- Comment #1 from Nils <mailm...@nilsb.dyndns.org> 2012-01-21 01:34:19 PST ---
This happens:
Array!T.Payload's destructor does
---
foreach (ref e; _payload) .clear(e);
---
where .clear is object.clear:
---
void clear(T)(T obj) if (is(T == class))
{
    rt_finalize(cast(void*)obj);
}
void clear(T)(ref T obj)
    if (!is(T == struct) && !is(T == class) && !_isStaticArray!T)
{
    obj = T.init;
}
---
(and other overloads that are not of interest)
That is, when object.clear is given a class instance reference, it destroys the
object, and when given a pointer (e.g. to a 'new'ed struct instance),
it nulls the pointer, but doesn't touch the pointer's target.

So maybe Array shouldn't call object.clear, or it should check for
!is(T == class). Or maybe object.clear shouldn't destroy class instances. To me
this would look more in line with the other versions of object.clear:
---
void clear(T)(ref T obj) if (is(T == class))
{
    obj = T.init;
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to