<div><font face="courier new, monospace">$ ./a.out</font></div><div><font face="courier new, monospace">dirent.cpp:4:19: fatal error: member access within misaligned address 0x7ffff752f787 for type 'struct dirent' requiring 8 byte alignment</font></div>
<div><div><span style="font-family:'courier new',monospace">zsh: illegal hardware instruction (core dumped)  ./a.out</span></div></div><div><div style="font-family:'courier new',monospace">$</div><div><font face="arial, helvetica, sans-serif"><br>
</font></div><div><font face="arial, helvetica, sans-serif">... coming soon to a -fcatch-undefined-behavior near you. Snippet, backtrace, etc. to follow.</font></div></div><br><div class="gmail_quote">On Wed, Sep 26, 2012 at 8:57 PM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank">silvas@purdue.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If you look at some of Richard's proposed changes to the undefined<br>
behavior checking, they include caret diagnostics (just like you're<br>
used to getting from clang). In this case (correct me if I'm wrong,<br>
Richard; I'm working from memory of the other thread), you'd get a<br>
nice, colorized output of something like:<br>
<br>
$ ./a.out<br>
Undefined behavior! Unaligned load from pointer 'd' (address<br>
0x7fb75880004c) of type 'struct dirent' that requires alignment 8:<br>
<div class="im">const char* local = d->d_name; // bam!<br>
</div>                           ^~~<br>
<span class="HOEnZb"><font color="#888888"><br>
--Sean Silva<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Wed, Sep 26, 2012 at 6:31 PM, Sean McBride <<a href="mailto:sean@rogue-research.com">sean@rogue-research.com</a>> wrote:<br>
> On Wed, 26 Sep 2012 14:04:51 -0700, Eli Friedman said:<br>
><br>
>>> So this is an OS X bug then?  (I'm pretty sure my code snippet itself<br>
>>is correct.)<br>
>><br>
>>Yes, it appears so.  (Not sure whether it's a bug in the header or a<br>
>>bug in the implementation.)<br>
><br>
> Ugh.  I was in 10.7.5, just tried in 10.8.2 and seems someone has already fixed this.<br>
><br>
> Anyway, I think it's a nice example of why fine-graned control over -fcatch-undefined-behavior would be nice: enabling it can find bugs that you can't fix.  If I could turn off the unaligned memory check, at least I could proceed and maybe find some bugs in my own code...<br>

><br>
> Thanks to all for helping.<br>
><br>
> Cheers,<br>
><br>
> --<br>
> ____________________________________________________________<br>
> Sean McBride, B. Eng                 <a href="mailto:sean@rogue-research.com">sean@rogue-research.com</a><br>
> Rogue Research                        <a href="http://www.rogue-research.com" target="_blank">www.rogue-research.com</a><br>
> Mac Software Developer              Montréal, Québec, Canada<br>
><br>
><br>
><br>
</div></div><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>