I\'ve been trying to understand the strict aliasing rules as they apply to the char pointer.
Here this is stated:
It is always presumed that a
Correct, the second example is in violation of the strict aliasing rules, so if you compile with the -fstrict-aliasing flag, there's a chance you may get incorrect object code. The fully correct solution would be to use a union here:
union
{
SocketMsgToRecv msg;
char msgBuff[100];
};
recv(socket, msgBuff, 100);
printf("Got Msg: a: %i, b: %i", msg.a, msg.b);