This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/53016] memcpy optimization can cause unaligned access on ARM
- From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 17 Apr 2012 14:37:13 +0000
- Subject: [Bug target/53016] memcpy optimization can cause unaligned access on ARM
- Auto-submitted: auto-generated
- References: <bug-53016-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53016
Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #3 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2012-04-17 14:37:13 UTC ---
child_t is a struct that requires 32-bit alignment, so the compiler is entitled
to assume that any pointer to an object containing a child_t will be correctly
aligned. The line:
const parent_t* parentptr = (const parent_t*)(data + 1);
violates that assumption, so your code has undefined behaviour. In this case
that turns out to be an alignment fault at run-time.