Hello, I do apologize if my ignorance is the problem here, but I am having a strange problem with the version of gcc included in suse 9.3: gcc version 3.3.5 20050117 (prerelease) (SUSE Linux). The same problem was observed with gcc 3.3.1. I have not tried later versions, but I can't find the problem in bugzilla so I assume it is either so trivial that I should be ashamed or unknown. It is an intel XEON processor.
It seems to me that if a,b, and c are float or double values and if a has been assigned b*c then a == (b*c) should return true since a should contain the same bitpattern as the temporary being assigned the value of b*c. Is it not so? Never the less, the following piece of code does not work as expected when compiling with -O0. It works FINE when compiling with -O1 or higher. ----------- #include <iostream> using namespace std; int main() { double b = 9.5245435435564536; double c = 7.98786542345446565; double a = b*c; //Does not work. cout << (a == (b*c)) << endl; // Works double d = b*c; cout << (a == d) << endl; } ----------- With O0 the output is 0 1 With O1, O2 or O3 the output is 1 1 as one would expect. I have made a similar program in C and I also changed double to float. It makes no difference. Nor does the actual float/double values. The optimization flag seems to decide what happens. Any insight would be appreciated. Andreas