[cfe-dev] -fcatch-undefined-behavior false positive with

David Blaikie dblaikie at gmail.com
Thu Sep 27 03:03:39 PDT 2012

MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

that is kind of awesome. Though, Richard, what're the thoughts on
fail-and-continue (unaligned reads in this case don't fail on this
platform do they? They're just possibly slower? (of course compilers
could still exploit this at some point, but the point of
-fcatch-undefined-behavior is to help us fix the issues before we
exploit those features (or after as a sanity check that the program was
already broken))) ot possible blacklists of known errors? Or both? Fail
and continue and log all the errors in order, suppress things in the
blacklist and then walk through the rest, fixing as many as possible
before iterating again for the next set of failures?
From: Sean McBride
Sent: 9/26/2012 11:48 PM
To: Richard Smith
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] -fcatch-undefined-behavior false positive with
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:

=09printf ("%p %zd r=3D%lu\n", d, _Alignof(*d), (uintptr_t)d % 8);

and now:

0x7fb758800000 8 r=3D0
0x7fb758800018 8 r=3D0
0x7fb758800030 8 r=3D0
0x7fb75880004c 8 r=3D4
0x7fb758800070 8 r=3D0
0x7fb758800094 8 r=3D4

Indeed the first non-aligned one crashes.  If I add an 'if' and skip all th=
e 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 co=


Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com=20
Mac Software Developer              Montr=C3=A9al, Qu=C3=A9bec, Canada

cfe-dev mailing list
cfe-dev at cs.uiuc.edu

More information about the cfe-dev mailing list