Memory corruption bug in struct dtor

Don don at nospam.com
Tue Jan 22 03:53:16 PST 2013


On Friday, 18 January 2013 at 20:14:23 UTC, H. S. Teoh wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=9352
>
> Seems like dtors are a minefield of hidden and dangerous bugs,

Yes. It's one of the worst areas. Postblit as well.

> due to
> them not being used (and therefore tested) very often. :-/

Not really. It's because it's an intrinsically difficult concept. 
The destructor is called at end-of-life of the struct. This means 
that in every possible part of the language, you have to know 
what the end-of-life is. So interaction with other parts of the 
language is inevitable, there's an explosion of special cases.

(By contrast, something like 'pure' is a very simple language 
feature: you just need to iterate over all the code that's marked 
pure, and generate an error if you find anything that isn't pure).


More information about the Digitalmars-d mailing list