This was discussed here: http://www.digitalmars.com/d/archives/digitalmars/D/TDPL_Manual_invocation_of_destructor_114875.html
On Mon, Sep 13, 2010 at 8:19 PM, Rob Grainger <[email protected]> wrote: > The following example is based on one from The D Programming Language. I'd > expect the last assertion in > the unittest to succeed, it fails. > > class Buffer { > private void* data; > > // Constructor > this () { > data = malloc(1024); > } > // Destructor > ~this() { > free(data); > data = null; > } > } > unittest { > auto b = new Buffer; > auto b1 = b; > clear(b); // Get rid of b's extra state > assert (b1.data is null); // Should be ok, fails > } >
