On Friday, 4 December 2015 at 01:35:45 UTC, deadalnix wrote:
First it check for alignement. Considering this :

On Thursday, 3 December 2015 at 09:11:12 UTC, Vladimir Panteleev wrote:
True, assuming that:

1. The pointers are still aligned at machine word boundaries

No. The pointer needs to be aligned as per underlying data type expectation. If it isn't aligned, the operation that produced this unaligned pointer must be unsafe, not the bitfield capability.

You misunderstood. The bitfield must *store* the pointers at addresses that are aligned at machine word boundaries.

3. The setters enforce that the discarded pointer bits were zero

If these bits aren't 0, the operation that set them to 1 is the one that is unsafe.

Well, that depends on how many bits are discarded? And that's not log2(T.sizeof). `cast(size_t)ptr % T.sizeof` may not be 0 in all cases.

4. No more than 4 bits are reused (as the smallest GC object size is 16 bytes)

Not correct. Considering the pointer is of type T*, then it is safe as long as align(T*) <= sizeof(T) which is correct on all architectures I know of (tho I wouldn't be surprised that some weird arch not used since the 70s may break this constraint).

I realized this was off after posting but I don't understand your reasoning either. The size and alignment just put a bound on the number of bits, but without verification in the setter you can't be sure, right?

Reply via email to