Walter:

> Hence my reluctance to add in a lot of these suggestions.

In an answer I've suggested the alternative solution of a 
-warn_fp_precision_loss compiler switch, that produces warnings only when you 
use it. In theory this avoids most of the Nagging Nellie problem, because you 
use this switch only in special situations. But I am aware you generally don't 
like warnings.


> As to the specific about erroring on reducing precision, my talks with people
> who actually do write a lot of FP code for a living is NO. They don't want it.
> Losing precision in FP calculations is a fact of life, and FP programmers 
> simply
> must understand it and deal with it. Having the compiler annoy you about it
> would be less than helpful.

Loss of some precision bits in normal FP operations is a fact of life, but 
double->float conversions usually lose a much more significant amount of 
precision, and it's not a fact of life, it's the code that in some way asks for 
this irreversible conversion.

A related problem your answer doesn't keep in account are unwanted 
float->double conversions (that get spotted by those error messages just 
because the code actually performs float->double->float conversions). Such 
unwanted conversions have caused performance loss on a 32-bit-mode CPU in some 
of my C code (maybe this problem is not present with CPU on 64 bit code), 
because the code was actually using doubles. A C lint has allowed me to spot 
such problems and fix them.

Thank you for your answers,
bye,
bearophile

Reply via email to