<br><br><div class="gmail_quote">On Fri, Jan 18, 2013 at 5:17 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">>> sanitize=undefined is giving me an error message about unaligned access to<br>
>> a size_t.  It's in a packed structure, and indeed is not 8 byte aligned<br>
>> (although it is 4 byte aligned.)<br>
><br>
</div><div class="im">> In short: because the C++ standard says so. -fsanitize=undefined is designed<br>
> to catch programs that have undefined behavior according to the C++<br>
> standard.<br>
<br>
</div>Surely the standard doesn't say anything about packed structures? If<br>
Clang supports them I'd expect accesses to be lowered to ones which<br>
the target supports (based on the DataLayout, perhaps amongst other<br>
things).<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br>The Standard simply says that access should be aligned at least to the natural alignment of the type. You are free to overalign but not to underalign.<br><br>Various compilers provide extensions to "pack" structures and a number of CPUs support unaligned accesses, but the Standard is concerned about ALL architectures and thus Standard compliant code should conform to alignment.<br>
<br>If possible you might be able to either:<br>- deactivate the check that is not applicable to your situation<br>- blacklist the functions/files that perform that check (doing so will remove *all* checks in the concerned functions/files though as far as I know)<br>
<br>-- Matthieu<br>