Unions destructors and GC precision

bearophile bearophileHUGS at lycos.com
Tue Aug 14 15:11:10 PDT 2012


Andrei Alexandrescu:

> That's pretty surprising. "Major bug" doesn't begin to describe 
> it.

If you want later I will add it to Bugzilla. But maybe before 
that other people will want to write some other comments in this 
thread.


> Unions should call no constructors and no destructors.

But this doesn't address the GC precision problem.

Some kind of tagging field (or equivalent information) isn't 
always available, but in many cases it's available, so in many 
practical cases I am able to put something useful inside a 
standard method like activeField(). If this method is available 
for the GC, it's not unconceivable to use it to call the right 
union field destructor when the union instance goes out of scope 
:-)

The precision of the GC is not a binary thing, even a not fully 
precise GC is useful, and probably more precision is better than 
less precision. Even if  activeField() is not always usable, an 
increase of GC precision seems an improvement to me.

Bye,
bearophile


More information about the Digitalmars-d mailing list