[cfe-dev] -fcatch-undefined-behavior false positive with readdir()?
richard at metafoo.co.uk
Wed Sep 26 23:05:20 PDT 2012
dirent.cpp:4:19: fatal error: member access within misaligned address
0x7ffff752f787 for type 'struct dirent' requiring 8 byte alignment
zsh: illegal hardware instruction (core dumped) ./a.out
... coming soon to a -fcatch-undefined-behavior near you. Snippet,
backtrace, etc. to follow.
On Wed, Sep 26, 2012 at 8:57 PM, Sean Silva <silvas at purdue.edu> wrote:
> If you look at some of Richard's proposed changes to the undefined
> behavior checking, they include caret diagnostics (just like you're
> used to getting from clang). In this case (correct me if I'm wrong,
> Richard; I'm working from memory of the other thread), you'd get a
> nice, colorized output of something like:
> $ ./a.out
> Undefined behavior! Unaligned load from pointer 'd' (address
> 0x7fb75880004c) of type 'struct dirent' that requires alignment 8:
> const char* local = d->d_name; // bam!
> --Sean Silva
> On Wed, Sep 26, 2012 at 6:31 PM, Sean McBride <sean at rogue-research.com>
> > On Wed, 26 Sep 2012 14:04:51 -0700, Eli Friedman said:
> >>> So this is an OS X bug then? (I'm pretty sure my code snippet itself
> >>is correct.)
> >>Yes, it appears so. (Not sure whether it's a bug in the header or a
> >>bug in the implementation.)
> > Ugh. I was in 10.7.5, just tried in 10.8.2 and seems someone has
> already fixed this.
> > 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...
> > Thanks to all for helping.
> > Cheers,
> > --
> > ____________________________________________________________
> > Sean McBride, B. Eng sean at rogue-research.com
> > Rogue Research www.rogue-research.com
> > Mac Software Developer Montréal, Québec, Canada
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev