Casting in Safe D
    "Nordlöw" via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sun Nov 23 11:37:43 PST 2014
    
    
  
I just noticed that
void foo() @safe pure nothrow
{
     void[] void_array = new void[3];
     auto ubyte_array = cast(ubyte[])void_array;
     auto short_array = cast(short[])void_array;
}
compiles but gives a
object.Error@(0): array cast misalignment
because of the
     cast(short[])
I'm surprised---why is cast between different alignments and 
element lengths allowed at all in Safe D?
IMO, cast(ubyte[]), should be safe here though.
    
    
More information about the Digitalmars-d-learn
mailing list