In my project we have a piece of code like this:
// raw data consists of 4 ints
unsigned char data[16];
int i1, i2, i3, i4;
i1 = *((int*)data);
i2 = *((int*
It's not alright, really. The alignment may be wrong, and the code may violate strict aliasing. You should unpack it explicitly.
i1 = data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;
etc. This is definitely well-defined behaviour, and as a bonus, it's also endianness-independent, unlike your pointer cast.