GC interpreting integer values as pointers

bearophile bearophileHUGS at lycos.com
Thu Oct 14 09:39:33 PDT 2010


Steven Schveighoffer:

> There are two problems here.  First, D has unions, so it is impossible for  
> the GC to determine if a union contains an integer or a pointer.

D has unions, and sometimes normal C-style unions are useful. But in many situations when you have a union you also keep a tag that represents the type, so in many of those situations you may use the tagged union of Phobos, std.variant.Algebraic (if the Phobos implementation is good enough, currently unfinished and not good enough yet) and the D GC may be aware and read and use the tag of an Algebraic union to know at runtime what's the type. This improves the GC precision a little.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list