convert ubyte[k..k + 1] to int

Roman D. Boiko rb at d-coding.com
Thu May 17 01:47:58 PDT 2012


On Thursday, 17 May 2012 at 08:39:21 UTC, Artur Skawina wrote:
> On 05/17/12 10:15, Roman D. Boiko wrote:
>> I mean, is it safe (assuming that we are allowed to mutate 
>> blob, and its length is a multiple of C.sizeof)?
>> 
>> I do casting from ubyte[] to C[].
>
> Only if C.ptr ends up properly aligned. There are also aliasing
> issues, which i don't think are sufficiently defined for D (for
> C, it would be legal only because char* is allowed to alias 
> anything).
>
> artur

Is it possible to ensure? In my case blob is created as
     auto blob = cast(ubyte[]) read(fileName);
I assume that alignment is safe.

But what should I do to be safe in a general case?


More information about the Digitalmars-d-learn mailing list