Bug#696205: g++-4.4: for condition fails with -O2
Package: g++-4.4
Version: 4.4.5-8
Severity: normal
When compiling the following simple program:
#include <iostream>
using namespace std;
int main()
{
for( int a = 0, b = 1; a >= 0 && b >= 0 ; ) {
cout << a << ", ";
int sum = a + b;
a = b;
b = sum;
}
}
If I use:
g++-4.4 -Wall -O2 -o fib fib.cc
Then the output doesn't stop when the value of a wraps into negative
territory.
If I use:
g++-4.4 -Wall -O0 -o fib fib.cc
Then it does stop, as expected.
- Chris
-- System Information:
Debian Release: 6.0.6
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 3.4.23 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Versions of packages g++-4.4 depends on:
ii gcc-4.4 4.4.5-8 The GNU C compiler
ii gcc-4.4-base 4.4.5-8 The GNU Compiler Collection (base
ii libc6 2.11.3-4 Embedded GNU C Library: Shared lib
ii libgmp3c2 2:4.3.2+dfsg-1 Multiprecision arithmetic library
ii libmpfr4 3.0.0-2 multiple precision floating-point
ii libstdc++6-4.4-dev 4.4.5-8 The GNU Standard C++ Library v3 (d
g++-4.4 recommends no packages.
Versions of packages g++-4.4 suggests:
pn g++-4.4-multilib <none> (no description available)
ii gcc-4.4-doc 4.4.4.nf1-1 documentation for the GNU compiler
pn libstdc++6-4.4-dbg <none> (no description available)
-- no debconf information
Reply to: