[cfe-dev] Possible clang bug with -O2, wrong if branch entered, in clang version 2.1 (tags/Apple/clang-163.7.1)

Dmitri Gribenko gribozavr at gmail.com
Tue Feb 21 07:57:01 PST 2012

On Tue, Feb 21, 2012 at 4:47 PM, Salvatore Sanfilippo <antirez at gmail.com> wrote:
> 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.


(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/

More information about the cfe-dev mailing list