Hi, I agree if you only read the C then the code looks fine, if a bit odd. However, having looked at the coredump with gdb it seems the compiler optomises the dereference out and passes back a pointer to the soon to be invalid stack address rather than the value. It only crashes with the stack protection on and I initially struggled to reproduce the issue as I was using the upstream compiler flags.
It isn't even handling endianness conversions as it copies the bytes in the same order they come in. I think their idea was to support architectures where you can't access an 32-bit int at an odd address. I'll try you patch and report back. Cheers, Scott