[Bug c++/16607] Incorrect FP code generated in member data initialization

npr1 at suomi24 dot fi gcc-bugzilla@gcc.gnu.org
Mon Jul 19 14:40:00 GMT 2004


------- Additional Comments From npr1 at suomi24 dot fi  2004-07-19 14:39 -------
Personally, I don't mind floats being imprecise in the last few bits, or doubles 
being imprecise in their last few bits. What I do mind is that after assigning 
float * float to double, that double value can have "simultaneously" two values 
that differ in almost half of their last bits. If this is allowed, one can never 
count on double having any more practical precision than float, especially with 
the duality being carried over [inlined] function calls. I'm sure many programs 
rely on this but, since it's broken so rarely it's not noticed until with a new 
compiler or a small non-related change in code structure. (Ouch!)

The "double = float * float" case could be fixed without performance issues, 
too. The compiler could well generate code that always uses the value with extra 
precision (that of double, or more). As I noted, the compiler already does this 
in all cases but the one. At least in my example, using two forms (single and 
double precision) of the result generates an unnecessary instruction, so 
actually there would be a performance increase.

I suppose a compiler patch could be too laborious compared to the gains, 
especially as it mustn't affect non-x86 compilations. My personal fix will be 
converting all uses of float to double, but obviously this is not good for all 
programs.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16607



More information about the Gcc-bugs mailing list