[cfe-dev] -fcatch-undefined-behavior false positive with readdir()?

Jeffrey Yasskin jyasskin at googlers.com
Wed Sep 26 15:52:15 PDT 2012

On Wed, Sep 26, 2012 at 3:31 PM, Sean McBride <sean at rogue-research.com> wrote:
> 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...

Note that you can work around this particular bug by using readdir_r()
with a dirent you allocate correctly.

More information about the cfe-dev mailing list