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

--- Comment #13 from safety0ff.bugz <safety0ff.b...@gmail.com> ---
(In reply to Pieter Penninckx from comment #9)
> 
> Am I right that the garbage collector currently works as follows:


It currently works as follows:

* Mark
* For each unmarked object:
*   Finalize it if necessary
*   If it can be released without overwriting it do so
* For each unmarked unreleased object:
*   release memory of the object

However, you shouldn't rely on this:
http://dlang.org/spec/class.html#destructors

If you recompile druntime with the MEMSTOMP option, the GC and it will write
arbitrary data to finalized memory.

Therefore it follows that referencing GC managed objects from invariants of
other GC managed objects is unadvised.

I think a case could be made for being able to control insertion of invariant
calls in destructors.

--

Reply via email to