Is comparing against 0.0 safe?

Brad Lucier
Tue Feb 15 17:38:00 GMT 2000


> In fact, does anyone mind if I add this extra documentation?

Yes.  It's naive numerical analysis that I can't imagine will help anyone
write a floating-point program of moderate size or sophistication.
(That was with my "Numerical Analysis Professor" hat on.)

Also, as a programmer, I generally feel more comfortable with the correctness
of my code if gcc compiles the code without complaint, even with more warnings
enabled.  Again, in my opinion, having floating-point code compile without
triggering *this* warning does not give me any added sense of safety.
In other words, as long as I'm working with gcc on an *86 machine with

1.  (more or less random) 64-bit register spills instead of 80-bit spills, and
2.  -ffloat-store not being sophisticated enough to ensure reproducibility
of values that one gets on machines without extra-precision registers

(so I can't write code that either consistently takes advantage of the
extra precision, or generates the same results as on machines without
the extra precision), then I don't think that gcc is a sophisticated enough
tool to warrant a warning that gives a false sense of well-being to naive
(and I mean naive, if this warning is going to help) floating-point programmers
whose code passes it.

So let's just leave it for people who see it and say "Hey, that's exactly
what I need" rather than trying to explain to them why they should need it.
(In which case, I'd probably like to try to explain to them why they
don't need it ;-)

Brad Lucier

More information about the Gcc mailing list