Accessing memory after destroy
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jul 30 00:58:19 PDT 2017
Johan Engelen wrote:
> If this is the case, then we really need to improve and pin-down the spec
> on this point.
>
> So `destroy` only calls the destructor and puts the object in
> `T.initializer` (non-constructed) state, and is otherwise not related to
> memory deallocation.
> May the destructor be called again when the GC collects the memory?
> Why is the object put in `T.initializer` state?
>
> To make sure: My question is from a spec point of view. Not about what
> currently happens and what is "OK" with the current implementation.
afair, somewhere in the spec there is a mention that dtor will be called
at most once for each initialized object. and object state doesn't have any
sense after calling dtor, but D still has to put something there, so
`.init` looks like a reasonable choice. althru i'm not sure that anything
in specs says that runtime *must* clear destroyed objects (they aren't
really usable after calling dtor anyway, it is at least a logical bug to use
object after destroying it).
More information about the Digitalmars-d
mailing list