On 17.11.2014 21:02, Martin Nowak wrote:
Walter is about to fix an old bug [1] so that invariants are now called
before destruction and for non-default construction.

A remaining question is whether invariants should also be called for
default construction [2].

[1]: https://github.com/D-Programming-Language/dmd/pull/4136
[2]: https://issues.dlang.org/show_bug.cgi?id=519#c11

I remember having an invariant on a tree structure checking consistency by verifying the children and parent references. This crashed when adding a destructor. With the proposed change it will always crash.

The problem is that the destructors of the tree nodes are called in arbitrary order when they are collected by the GC. Class instances are also made invalid after calling the destructor (the vtbl is zeroed).

I wonder if

- such invariants are invalid,
- the GC should bypass the invariant when calling the destructor
- or we should never call the invariant with the destructor?

Reply via email to