On Tue, May 21, 2019 at 12:31 PM Hamad Ahmed <ahmed90@xxxxxxxxxx> wrote: > > That's why I am asking if it is easy to put in a compiler option like -fgarbage. When > > it is enabled, gcc should put in an extra instruction to zero out a register because > > gcc knows when a variable dies (won't be used anymore in the program) because > > it uses this information to do a lot of optimizations. I completely support adding better support to GCC for garbage collection--we could use it for Go. But this specific idea is just a part of that, and not the hardest part. The compiler is also fully capable of producing pointers that should hold a memory block live but do not actually point into that memory block--they point just past the end or earlier than the beginning, and the compiler uses offset calculations for all accesses. This does happen for certain kinds of loops. Also, some floating point values look exactly like pointers, so if you want reliable garbage collection you need to know whether a value is a pointer or not, but the compiler does not tell you that. Ian