When comparing the return value of two functions (which both return double and do always return the same value), I have the case that (a < b) && (b < a) (whereby they should be equal) in a real world application.
I tried to reproduce it, though in the test case, I have a slightly different case, which should be also wrong: !(a < b) && (b > a) is true (whereby it should be a == b). Probably both problems are related. The behaviour pretty much depend on the optimisation. With -O0 and -Os, I am hitting the problem, but not so with -O1, -O2 and -O3. -- Summary: floating point comparision works wrong ( !(a < b) && (b > a) is true ) Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ich at az2000 dot de GCC build triplet: tried with GCC 4.1.2, 4.3.2 and 4.4.0 GCC host triplet: Gentoo Linux i386 GCC target triplet: Linux i386 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40186