This is so so weird. As far as I can tell, this is a g++ optimization bug. I'd love to hear that it's not, but it certainly seems that way.
Here's the original code: //above is some code that sets s1 and s2, // which are both doubles. if(s1 < s2) { cerr << (s1 < s2 ) << endl; cerr << (s1 > s2 ) << endl; cerr << (s1 == s2 ) << endl; cerr << s1 - s2 << endl; return true; } If I compile it with options t -Wall -G -DNDEBUG -DLinux the output is blank. It skips the inside of the loop because s1 is not less than s2. But if I compile it with an addition -O3 the output is: 0 0 1 0 and true is returned. What confuses me is how can the first 0 ever be printed. If it enters the if statement then s1 < s2, so the first check should always be true. But it's not. With in the look it is indicating that s1 == s2. So how did it get in in the first place? Stranger yet, if I compile the following code with -O3, it skips the 'if' clause entirely and works fine. The only difference is that I added some cerr statements. cerr << s1 << endl; cerr << s2 << endl; cerr << (s1 < s2) << endl ; if(s1 < s2) { cerr << (s1 < s2 ) << endl; cerr << (s1 > s2 ) << endl; cerr << (s1 == s2 ) << endl; cerr << s1 - s2 << endl; return true; } I'm running g++ v 4.0 on RedHat [EMAIL PROTECTED] src]$ g++4 -v Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --with-gxx-include-dir=/usr/include/c++/3.4.3 --enable-libgcj-multifile --enable-languages=c,c++,java,f95 --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux Thread model: posix gcc version 4.0.2 20051130 (Red Hat 4.0.2-14.EL4) [EMAIL PROTECTED] src]$ uname -a Linux 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 i686 i386 GNU/Linux [EMAIL PROTECTED] src]$ uname -a gives: Linux c6.cs.nyu.edu 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:54:53 EST 2006 i686 i686 i386 GNU/Linux Thanks! _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus