More precise GC
Robert Jacques
sandford at jhu.edu
Sun Mar 28 20:25:36 PDT 2010
On Sun, 28 Mar 2010 13:50:20 -0300, bearophile <bearophileHUGS at lycos.com>
wrote:
> Robert Jacques:
>> 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
Yes, hiding bit flags in pointers is generally a bad idea because it makes
your code dependent on a particular GC/CPU system. Though I do think
storing a single bit is going to work on anything greater than a 8-bit
system.
More information about the Digitalmars-d
mailing list