Re: Compiler optimization problem in MSVC 2003 Release mode

Thanks. I always get stumped with what the compiler does
automatically. Sometimes it helps and sometimes it just screws up. By
the way, is there some place i can read up more on this, or is there a
heading to search in google.

It works fine in debug mode giving output of 0 but in release it gives
1.

Try making it

int cmpFloat_to_Double(volatile float x, double y)

That should hopefully suppress optimizations. Alternatively, you can
compile with /Op flag. Without this flag, the optimizer is allowed to
perform floating point calculations at a precision higher than that
dictated by the variable's type (e.g., delaying conversion from double
to float until the value has to be spilled from FPU register to memory).
Which, of course, completely defeats your exercise.

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925