Robert Jacques: >What I think you're forgetting is that all compile-time type info is lost at >runtime. [... etc]<
Thank you very much for all your explanations, I didn't know that the situation is so terrible. I suddenly like not-GC languages more :-) I think the compilation of D code must build a data structure that will be used at runtime by the GC to know the type of all variables and pointers, otherwise there's no hope in a GC that works well in long-running programs. What you have explained me means that my gcfollow is useless (it has another minor problem: sometimes the information regarding the contents of the union is not inside the struct fields, so the gcfollow can have troubles in finding such information far away). > No, what you can't do is hide flags in high order bits or use tricks like > XOR to store two pointers in a single field. The 4 low order bits are fair > game: This page: http://www.digitalmars.com/d/2.0/garbage.html Says: Do not take advantage of alignment of pointers to store bit flags in the low order bits: p = cast(void*)(cast(int)p | 1); // error: undefined behavior Bye, bearophile