grauzone schrieb:
First the anti-feature: [0xAB, ...] will yield an int[], not a ubyte[] (I guess ubyte[] is what you're expecting). If you cast two arrays, the compiler will reinterpret cast all data. The result won't be what you intended.

Yeah I already encountered that problem. That's why I had to cast(ubyte[]) it (where conversion is expected) for my reinterpret casting:

RGB[] PALETTE = (cast(RGB*) cast(ubyte[]) [...])[0..256];


Second, the bug: casting arrays at compiletime seems to behave differently from casting at runtime. Casting at compiletime doesn't reinterpret cast, it does conversion! Demonstration here: http://codepad.org/OGjXADdu


You're right. But it only concerns casting to a struct(?) or an array of structs, right?!. Conversion is correct for standard arrays, but struct arrays need to be reinterpret cast (correct me if I'm wrong, I can't imagine how conversion could be reasonably used. Only thing might be casting an array of structs to another array of structs but I don't know any valid use-case).

Reply via email to