[cfe-dev] Possible clang bug with -O2, wrong if branch entered, in clang version 2.1 (tags/Apple/clang-163.7.1)
jonathan.sauer at gmx.de
Tue Feb 21 11:04:33 CST 2012
>>> Sorry, there was a problem with cut&paste of the gist URL, the correct
>> one is:
>> 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:
Is there a reason why integer overflow checks are only inserted with -ftrapv, but not with
-fcatch-undefined-behavior? (clang r151042)
More information about the cfe-dev