If I have a struct declared like the following:
volatile struct { uint8_t foo; int16_t bar[1]; } __attribute__((packed)) foobar;
The code emitted uses LDRSH to access bar[0] and causes a hardfault at runtime. But If I were to declared it using the __packed qualifier:
__packed volatile struct { uint8_t foo; int16_t bar[1]; } foobar;
Then the compiler correctly recognizes the potential misalignment and emits LDRB instead. Is this the expected behavior? I'm using uVision v5.17 with Armcc v5.06 update 1 (build 61). Thanks.