[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jul 5 02:14:37 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=2834

Dmitry Olshansky <dmitry.olsh at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh at gmail.com

--- Comment #20 from Dmitry Olshansky <dmitry.olsh at gmail.com> ---
(In reply to Orvid King from comment #19)
> We still wouldn't be able to call the destructors in structs for arrays even 
> with precise heap scanning, because we can't know that each value in the
> array 
> is actually valid. Take for instance an array of File's, it's not valid to
> call 
> the destructor of File.init, so we could compare the value of an element of
> an 
> array of structs to it's init value, but who's to say that element was ever 
> initialized in the first place? How would we detect that?

It's perfectly valid to call destructor on T.init. In fact compiler will always
do so with stack-allocated instances.

--


More information about the Digitalmars-d-bugs mailing list