5 ms·
I'm afraid you are only slightly correct. Architectures are generally optimized for aligned access (or disallow unaligned access), but what counts as "aligned"
by gavinhoward 3y ago
I'm afraid you are only slightly correct.
Architectures are generally optimized for aligned access (or disallow unaligned access), but what counts as "aligned" is different for each type.
A char type that is used for a bool can be accessed on any byte boundary because the alignment of a char is 1. The alignment of a 32-bit value is 4.
However, architectures are generally more optimized for 32-bit operations in registers. If you're dealing with a char in a register, the compiler will generally treat it as a 32-bit value, clearing the top bits. (This is one of those places where C's UB can bite you.)
However, there are architectures where 32-bit access is optimized.
- deleted 3y ago[deleted]