I have the following code that is exhibiting some very strange behavior. does anyone have any idea why.
#include <iostream>
long global = 20001;
double foo() {return global / 1000.0;}
int main(int,char**) {
  if (foo() == foo()) {
    std::cout << "true\n";
  } else {
    std::cout << "false\n";
  }
  return 0;
}
This should print true as the function returns the same result each time but instead prints false;
This is built using g++ on Solaris 10. I don't know that the OS matter, but I haven't had a chance to try it on a different os
 
     
     
    