Question about garbage collection specification

rsw0x via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 15 08:33:39 PDT 2015


On Monday, 15 June 2015 at 12:08:31 UTC, Dmitry Olshansky wrote:
> On 13-Jun-2015 14:32, rsw0x wrote:
>> http://dlang.org/garbage.html
>>
>> 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
>>
>> if this restriction is actually imposed - why does
>> std.bitmanip.tagged{ClassRef,Pointer} even exist?
>
> AFAIK the restriction was that pointers _themselves_ have to be 
> stored at word-aligned addresses. This allows GC to scan memory 
> cheaper w/o considering if some misaligned address may contain 
> a pointer.

this doesn't make any sense, it's referring to an object p (of 
void*), not the location of p. It's setting the lsb of p to 1 and 
claiming it's undefined behavior, when it's clearly not.

Unless I misunderstand it.


More information about the Digitalmars-d mailing list