[cfe-dev] Possible clang bug with -O2, wrong if branch entered, in clang version 2.1 (tags/Apple/clang-163.7.1)
Sean McBride
sean at rogue-research.com
Tue Feb 21 08:13:51 PST 2012
On Tue, 21 Feb 2012 17:57:01 +0200, Dmitri Gribenko said:
>> Sorry, there was a problem with cut&paste of the gist URL, the correct
>one is:
>>
>> https://gist.github.com/1876875
>
>Hi Salvatore,
>
>If I understand this code correctly, there is a signed overflow.
>Signed overflow is undefined behavior. Clang (or LLVM) apparently
>takes advantage of that by optimizing (incr < 0 && value > oldvalue)
>=> false.
And you can get clang to barf on such occurrences:
<http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html>
--
____________________________________________________________
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