[cfe-dev] -fsanitize=undefined and alignment on x86_64

Martin Martin martin at silverliningsystems.com
Fri Jan 18 04:21:27 PST 2013


Hi all,

sanitize=undefined is giving me an error message about unaligned access to
a size_t.  It's in a packed structure, and indeed is not 8 byte aligned
(although it is 4 byte aligned.)  This is in Linux on an x86_64
architecture.

My question is: why is this undefined behavior?  Can't modern Intel and AMD
processors accesses unaligned ints, although with a possible performance
penalty?  So this would be a performance problem, but not correctness?  Is
the problem that the compiler could use SSE or some other instructions that
require alignment and will seg fault or give wrong results with unaligned
access?

Best,
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130118/8c81d3c3/attachment.html>


More information about the cfe-dev mailing list