[cfe-dev] -fcatch-undefined-behavior false positive with readdir()?
Sean McBride
sean at rogue-research.com
Wed Sep 26 13:44:43 PDT 2012
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.)
Cheers,
--
____________________________________________________________
Sean McBride, B. Eng sean at rogue-research.com
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
More information about the cfe-dev
mailing list