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.

2. The underlying storage type is one that the GC will scan for pointers (e.g. void or void*, not size_t/ubyte)

Yes, this one is not a problem currently, but can be (and in fact should be with a better GC). Hopefully, this is something I want to improve already and not a blocker considering the API, just an implementation detail.

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.

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).

The only valid concern here is 2. , but currently not a problem with the GC we have, and simply an implementation issue.

Reply via email to