http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47273
--- Comment #6 from Waldemar Valdas Bancewicz <waldemarbancewicz at ruggedcom dot com> 2011-01-14 15:42:57 UTC --- About Comment #4: This is a question to the GCC/G++ team. How are unaligned pointers dealt with? I came up with the following possible options: (1) Compiler inserts the following code whenever a pointer is dereferenced: if &b is aligned return address of b else do aligned read before pointer and after pointer, bitshift and mask each read and merge to get data Problems with this approach: - Unnecessary extra operations for each aligned pointer dereference. - The else part needs to be atomic and, since most architectures don't have such an atomic operation, we need to insert a disable interrupts and enable interrupts pair. It would be weird pushing this responsibility to the compiler since a compiler, in general, shouldn't know anything about how interrupts are implemented for a particular architecture. (2) Compiler pushes the responsibility to the hardware. (2.1) An unaligned memory accesses causes an exception and the above "else" part is done in the ISR. (2.2) An unaligned memory accesses is dealt with hardware. I don't see how option #1 is possible so, to my limited understanding, the compiler shouldn't care if memory accesses are aligned or not.