--- Comment #3 from brian at dessent dot net 2008-07-17 10:21 ---
Subject: Re: New: Optimization O2 causes infinite loop
Yes, this code is broken as indeed overflow of signed integers is
undefined, so transforming this to an infinite loop is legitimate. Here
are some links to read:
--- Comment #2 from paolo dot carlini at oracle dot com 2008-07-17 10:06
---
(In reply to comment #0)
>int bit;
>for( bit = 1; bit; bit *= 2 )
This is pretty straightforward, isn't it? At some point bit - a *signed*
integral type - overflows and this leads to undefined bahavior
--- Comment #1 from ben at zeus dot com 2008-07-17 09:53 ---
Sorry, forgot to include any compiler details:
[hera ben]$ /usr/local/gcc-4.3/bin/gcc -O2 -v -save-temps loop.c
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3.1/configure --prefi