This is the mail archive of the
mailing list for the GCC project.
Re: Fourth Draft "Unsafe fp optimizations" project description.
- To: lucier at math dot purdue dot edu, syedali011 at earthlink dot net
- Subject: Re: Fourth Draft "Unsafe fp optimizations" project description.
- From: dewar at gnat dot com
- Date: Wed, 15 Aug 2001 18:22:00 -0400 (EDT)
- Cc: ejr at cs dot berkeley dot edu, gcc at gcc dot gnu dot org, kaih at khms dot westfalen dot de
<<test.c:4: warning: comparing floating point with == or != is unsafe
This is an annoying warning, because it is nonsense. There are many
situations in which it makes perfectly good sense to compare floating
point numbers if you know what you are doing. Remember there is nothing
"approximate" about floating-point, it is a well defined axiomatic system
in which you can reason about your programs, and equality tests make
yes, they can be misused, but so can subtraction, I don't think you want
to give warnings like:
a = b - c;
warning floating-point subtraction may cause loss of significance.
It is particularly annoying that the messages says *is* unsafe, instead
of something like "may be" unsafe.
Warnings should be about constructs in the language that are legal, but
in some situations are likely to be clear programming errors.
To give a warning on every instance of the use of a construct in the language,
saying essentially "warning, this feature of the language should not be used"
is contentious from the start. Why do you think floating-point equality
was allowed in C (or in Fortran, Ada, COBOL, PL/1, Algol, and virtually
every other programming language ever designed)? Presumably the writer
of this warning thinks that was a mistake.
So it is almost never justified to give a warning for all uses of a feature
in a language, it is even less justified when the warning comes from
misguided ignorance :-)