http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56550
Bug #: 56550 Summary: cortex-m3: incorrect write to member of volatile packed structure Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: critical Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: jblacka...@gmail.com GCC generates invalid write access instructions for unaligned member of volatile packed structure on ARM Cortex-M3 target. Simple testcase compiled with "arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -g3 -gdwarf-2 -nostartfiles testcase.c -o testcase.elf": #include <stdint.h> struct _test_struct_t { uint8_t m1; uint8_t m2; uint32_t m3; uint8_t m4; uint32_t m5; } __attribute__((packed)); volatile struct _test_struct_t test_struct; int main(void) { int test_var = 0xFFFFFF01; test_struct.m5 = test_var; // here test_struct.m5 == 0x01 return 0; } When I remove m1,m2,m3, result is 0xFFFF01. When I remove m1, m2, m3, m4, result become correct. I tested it in Yagarto ARM toolchain (win32 build) with gcc versions 4.7.2 and 4.6.0 both. This situation looks similar to #48784 and #20102.