On Sunday, 24 August 2014 at 08:48:03 UTC, bearophile wrote:
Perhaps there are ways, but note that @nogc is meant mostly for stack-allocation.
Ah, I missed that. Thanks for telling me. I changed nogcDel now to null out the deallocated object:
void nogcDel(T)(ref T obj) { import core.stdc.stdlib : free; // calls obj's destructor destroy(obj); // free memory occupied by object free(cast(void*)obj); obj = null; } And now I also get the dearly missed protection violation ;-).