tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Compiler is too smart: lang/openjdk7 build fails



  Hello!

cc1plus: warnings being treated as errors
/tmp/lang/openjdk7/work/openjdk/hotspot/src/share/vm/runtime/sharedRuntimeTrans.cpp:
 In function 'double __ieee754_pow(double, double)':
/tmp/lang/openjdk7/work/openjdk/hotspot/src/share/vm/runtime/sharedRuntimeTrans.cpp:575:
 warning: division by zero in '0.0 / 0.'
/tmp/lang/openjdk7/work/openjdk/hotspot/src/share/vm/runtime/sharedRuntimeTrans.cpp:586:
 warning: division by zero in '0.0 / 0.'
gmake[6]: *** [sharedRuntimeTrans.o] Error 1


Try to outsmart compiler:

--- hotspot/src/share/vm/runtime/sharedRuntimeTrans.cpp.orig    2009-12-17 
12:44:32.000000000 +0300
+++ hotspot/src/share/vm/runtime/sharedRuntimeTrans.cpp 2010-04-03 
06:28:12.000000000 +0400
@@ -572,7 +572,7 @@
       if(hy<0) z = one/z;       /* z = (1/|x|) */
       if(hx<0) {
         if(((ix-0x3ff00000)|yisint)==0) {
-          z = (z-z)/(z-z); /* (-1)**non-int is NaN */
+          z = strtod("0.0", NULL)/strtod("0.0", NULL); /* (-1)**non-int is NaN 
*/
         } else if(yisint==1)
           z = -1.0*z;           /* (x<0)**odd = -(|x|**odd) */
       }
@@ -583,7 +583,7 @@
   n = (hx>>31)+1;
 
   /* (x<0)**(non-int) is NaN */
-  if((n|yisint)==0) return (x-x)/(x-x);
+  if((n|yisint)==0) return strtod("0.0", NULL)/strtod("0.0", NULL);
 
   s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
   if((n|(yisint-1))==0) s = -one;/* (-ve)**(odd int) */


This problem occurs too frequently, it would be nice to have some
recommendation(s) on how to do that properly.
Should we use nan(3)?


-- 
HE CE3OH...

Attachment: pgplGzsyUnuxC.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index