This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/53016] memcpy optimization can cause unaligned access on ARM


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]