Neat project: add pointer capability to std.bitmanip.bitfields

Marc Schütz via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 3 06:28:01 PST 2015


On Thursday, 3 December 2015 at 13:02:24 UTC, Steven 
Schveighoffer wrote:
> First I will say, there is confusion on what is valid and what 
> is not. Misaligned pointers are pointers that are stored 
> misaligned. In other words, they are stored not on a 4-byte or 
> 8-byte boundary for 32 bits or 64 bits arch respectively.
>
> An interior pointer is a pointer that is *properly aligned* but 
> does not point at the first byte of a piece of memory. 
> taggedPointer and taggedClassRef create *interior pointers*, 
> not *misaligned pointers*. Andrei's proposal will create 
> *misaligned pointers*. There is a huge difference.
>
> I can make an interior pointer without casts on any type:
>
> SomeType *pointer = ...;
> void[] p = pointer[0..1];
> p = p[1..$];
>
> If the GC does not support this being the only pointer to a 
> memory location, then the GC is not suitable for D. Period. 
> Code will break in subtle ways if you use such a GC.
>
> I can't see how a language with void* and/or unions could allow 
> such a GC.

Indeed, I was talking about interior pointers. But you're right, 
I missed the fact that void pointers (and some others) can be 
valid interior pointers even to unstructured values. So the 
optimization I had in mind is not applicable in D, anyway.

We should then just adjust the specification to specifically 
allow changing the LSBs.


More information about the Digitalmars-d mailing list