Fourth Draft "Unsafe fp optimizations" project description.
akbara
syedali011@earthlink.net
Wed Aug 15 15:22:00 GMT 2001
>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"
good point.
> warning floating-point subtraction may cause loss of significance.
but imho, it's not as significant as an equality test.
doing something like if (blah_justcomputed == thevalue) could result into a lot of wasted time.
esp for the begginer who is learning how to implement various floating point intensive algorithms.
but then again, in most numerical anaylsis books; one of the first things they discuss are the numerical errors that come
up when writing software..
what do the others think about this warning?
-akbar A.
On Wed, 15 Aug 2001 18:22:00 -0400 (EDT)
dewar@gnat.com wrote:
> <<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
> perfect sense.
>
> 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 :-)
--
"it's called Mario Twins, and I WANT TO PLAY IT"
http://vertexabuse.cjb.net
More information about the Gcc
mailing list