News for hackers. Stuff that matters.
Re:GCC optimized code gives strange floating point results by wallacoloo on Sunday February 26, 2017 @05:05PM (#13740240)
This is a good explanation, but the conclusion that this isn't a GCC bug is false. y and y2 both have type annotations of "double" at the point they're compared. They should be computed using an intermediate of type "long double", and then casted to double. But GCC is incorrectly comparing them based on those intermediate values instead of their final values.

In a more extreme case, let's say I had two strings: v="1.0" and w="+1.0". atof(v) and atof(w) should ABSOLUTELY compare equal. The logic followed by GCC effectively says that it's OK to compare them by their intermediate string representation instead, though, wherein they would compare as non-equal.

There are no comments on this comment yet.