This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/56550] New: cortex-m3: incorrect write to member of volatile packed structure
- From: "jblackarty at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 06 Mar 2013 10:45:36 +0000
- Subject: [Bug target/56550] New: cortex-m3: incorrect write to member of volatile packed structure
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: jblackarty@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.