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

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
For the tests in comment 1, I think PR323 strikes back again. I the same
results for both -m32 and -m64 with the following patch

--- ../_clean/libgfortran/io/write_float.def    2014-01-04 15:51:53.000000000
+0100
+++ libgfortran/io/write_float.def    2014-01-12 15:55:24.000000000 +0100
@@ -1043,10 +1043,11 @@ output_float_FMT_G_ ## x (st_parameter_d
     break;\
     }\
 \
-  rexp_d = calculate_exp_ ## x (-d);\
-  if ((m > 0.0 && ((m < 0.1 - 0.1 * r * rexp_d) || (rexp_d * (m + r) >=
1.0)))\
+  rexp_d = calculate_exp_ ## x (d);\
+  if ((m > 0.0 && ((10.0 * rexp_d * m < rexp_d - r ) || ((m + r) >= rexp_d)))\
       || ((m == 0.0) && !(compile_options.allow_std\
-              & (GFC_STD_F2003 | GFC_STD_F2008))))\
+              & (GFC_STD_F2003 | GFC_STD_F2008)))\
+      ||  d == 0)\
     { \
       newf.format = FMT_E;\
       newf.u.real.w = w;\
@@ -1069,7 +1070,7 @@ output_float_FMT_G_ ## x (st_parameter_d
       volatile GFC_REAL_ ## x temp;\
       mid = (low + high) / 2;\
 \
-      temp = (calculate_exp_ ## x (mid - 1) * (1 - r * rexp_d));\
+      temp = (calculate_exp_ ## x (mid - 1) * (rexp_d - r) / rexp_d);\
 \
       if (m < temp)\
         { \

I think in order to avoid overflows (10.0 * rexp_d * m < rexp_d - r ) and ((m +
r) >= rexp_d) should be exchanged.

Reply via email to