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

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 4 16:33:15 PST 2015


On Friday, 4 December 2015 at 23:38:08 UTC, deadalnix wrote:
> On Friday, 4 December 2015 at 10:31:19 UTC, Vladimir Panteleev 
> wrote:
>> 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?
>
> If one of the bit within the alignment is not 0, that mean you 
> did something unsafe previously to create that pointer.

But this only applies to ... pointers to pointers, right? In D, 
only pointer variables have to be aligned to maintain safety, and 
even then that only applies to GC pointers (a C function may 
return an "unaligned" pointer pointer). struct { align(1): ubyte 
a; int b; } is still quite safe, and so is interpreting a pointer 
into an array of ubytes as an uint.



More information about the Digitalmars-d mailing list