On Thu, 29 May 2014 09:57:40 -0400, Adam D. Ruppe <destructiona...@gmail.com> wrote:

On Thursday, 29 May 2014 at 13:01:50 UTC, Szymon Gatner wrote:
Later in same chapter: "... or being collected by the garbage collector—its destructor is called, if present."

Is that really true?

hmm, you seem to be right, but this might be a bug. I'm pretty sure the struct dtors were called on arrays not long ago but it isn't really reliable with the GC (My weasel word there is "provably", sometimes the GC can't prove there are no references; false pointers etc) but still blargh this current reality seems weird.

The GC never has called struct destructors for arrays of structs or individual structs allocated on the heap.

It will call destructors on structs that are members of classes ONLY because the class destructor will call the struct destructor.

One other situation a heap allocated struct will have it's destructor called (I think) is due to a closure allocation, but I'm not 100% sure how that works. A way to verify is to make a closure occur, then test the closure's block to see if FINALIZE flag is set on it.


Reply via email to