[cfe-dev] -fcatch-undefined-behavior false positive with readdir()?
eli.friedman at gmail.com
Wed Sep 26 14:04:51 PDT 2012
On Wed, Sep 26, 2012 at 1:44 PM, Sean McBride <sean at rogue-research.com> wrote:
> On Wed, 26 Sep 2012 12:59:23 -0700, Richard Smith said:
>>> It prints 8, for every iteration of the loop. I guess that's correct
>>> since the first field of the struct is a uint64_t.
>>What pointer values does it print? Are they 8 byte aligned?
> Aha! So I changed your printf() to:
> printf ("%p %zd r=%lu\n", d, _Alignof(*d), (uintptr_t)d % 8);
> and now:
> 0x7fb758800000 8 r=0
> 0x7fb758800018 8 r=0
> 0x7fb758800030 8 r=0
> 0x7fb75880004c 8 r=4
> 0x7fb758800070 8 r=0
> 0x7fb758800094 8 r=4
> Indeed the first non-aligned one crashes. If I add an 'if' and skip all the non 8 byte aligned ones, -fcatch-undefined-behavior no longer complains.
> 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.)
More information about the cfe-dev