http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57911
Bug ID: 57911 Summary: alignment of arrays allocated stack on ARM : 4 bytes ? Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: yann at droneaud dot fr Hi Following discussion in bug #57908, especially bug #57908 comment #1, on ARMv7, I'm very surprised that array of bytes are aligned on 4 bytes boundary when allocated on stack. Using attachment #30512, I'm able to produce the following results using GCC arm-none-linux-gnueabi-gcc (Sourcery CodeBench Lite 2013.05-24) 4.7.3. Another custom GCC 4.7.2 produces same results. with default option: kind name address size alignment required type | uint8_t | N/A | 1 | N/A | 1 type | uint8_t[2] | N/A | 2 | N/A | 1 Arrays object | u8_0 | 0xf6fff00c | 1 | 4 | 1 object | u8_1 | 0xf6fff008 | 3 | 8 | 1 object | u8_2 | 0xf6fff000 | 7 | 4096 | 1 object | u8_3 | 0xf6ffeff8 | 5 | 8 | 1 object | u8_4 | 0xf6ffeff4 | 2 | 4 | 1 object | u8_5 | 0xf6ffeff0 | 1 | 16 | 1 object | u8_6 | 0xf6ffefec | 3 | 4 | 1 object | u8_7 | 0xf6ffefe4 | 5 | 4 | 1 object | u8_8 | 0xf6ffefdc | 7 | 4 | 1 object | u8_9 | 0xf6ffefd8 | 2 | 8 | 1 object | u8_10 | 0xf6ffefcc | 11 | 4 | 1 object | u8_11 | 0xf6ffefc8 | 3 | 8 | 1 object | u8_12 | 0xf6ffefb8 | 13 | 8 | 1 object | u8_13 | 0xf6ffefb4 | 2 | 4 | 1 object | u8_14 | 0xf6ffefb0 | 1 | 16 | 1 object | u8_15 | 0xf6ffefac | 2 | 4 | 1 with -Os: kind name address size alignment required type | uint8_t | N/A | 1 | N/A | 1 type | uint8_t[2] | N/A | 2 | N/A | 1 Arrays object | u8_0 | 0xf6ffef9c | 1 | 4 | 1 object | u8_1 | 0xf6ffefb8 | 3 | 8 | 1 object | u8_2 | 0xf6ffefd4 | 7 | 4 | 1 object | u8_3 | 0xf6ffefc4 | 5 | 4 | 1 object | u8_4 | 0xf6ffefa8 | 2 | 8 | 1 object | u8_5 | 0xf6ffefa0 | 1 | 32 | 1 object | u8_6 | 0xf6ffefbc | 3 | 4 | 1 object | u8_7 | 0xf6ffefcc | 5 | 4 | 1 object | u8_8 | 0xf6ffefdc | 7 | 4 | 1 object | u8_9 | 0xf6ffefac | 2 | 4 | 1 object | u8_10 | 0xf6ffefe4 | 11 | 4 | 1 object | u8_11 | 0xf6ffefc0 | 3 | 64 | 1 object | u8_12 | 0xf6ffeff0 | 13 | 16 | 1 object | u8_13 | 0xf6ffefb0 | 2 | 16 | 1 object | u8_14 | 0xf6ffefa4 | 1 | 4 | 1 object | u8_15 | 0xf6ffefb4 | 2 | 4 | 1 I'm reading AAPCS (IHI0042E) and I don't found any requirement for array allocated on stack to be aligned on 4 bytes. It's a pity that -Os, as suggested by Andrew Pinski in bug #57908 comment #7, doesn't align the array on 1 bytes boundary.