[Bug fortran/60128] [4.8/4.9 Regression] Wrong ouput using en edit descriptor

dominiq at lps dot ens.fr gcc-bugzilla@gcc.gnu.org
Mon Feb 10 11:36:00 GMT 2014


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

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The regression reported in comment 3 disappears with the following patch

--- ../_clean/libgfortran/io/write_float.def    2014-01-21 08:30:57.000000000
+0100
+++ libgfortran/io/write_float.def    2014-02-10 11:35:55.000000000 +0100

@@ -326,7 +322,7 @@ output_float (st_parameter_dt *dtp, cons
      for IEEE 754, this ought to be round to nearest, ties to
      even, corresponding to the Fortran ROUND='NEAREST'.  */
       case ROUND_PROCDEFINED: 
-      case ROUND_UNSPECIFIED:
+      /* case ROUND_UNSPECIFIED: */
       case ROUND_ZERO: /* Do nothing and truncation occurs.  */
     goto skip;
       case ROUND_UP:
@@ -338,6 +334,7 @@ output_float (st_parameter_dt *dtp, cons
       goto skip;
     goto updown;
       case ROUND_NEAREST:
+      case ROUND_UNSPECIFIED:
     /* Round compatible unless there is a tie. A tie is a 5 with
        all trailing zero's.  */
     i = nafter + nbefore;
@@ -1215,8 +1212,8 @@ determine_en_precision (st_parameter_dt 
     nbefore = 3 - nbefore;
     }
   int prec = f->u.real.d + nbefore;
-  if (dtp->u.p.current_unit->round_status != ROUND_UNSPECIFIED
-      && dtp->u.p.current_unit->round_status != ROUND_PROCDEFINED)
+  /* if (dtp->u.p.current_unit->round_status != ROUND_UNSPECIFIED
+      && dtp->u.p.current_unit->round_status != ROUND_PROCDEFINED) */
     prec += 2 * len + 4;
   return prec;
 }

>From the comment

      /* For processor defined and unspecified rounding we use
         snprintf to print the exact number of digits needed, and thus
         let snprintf handle the rounding.  On system claiming support
         for IEEE 754, this ought to be round to nearest, ties to
         even, corresponding to the Fortran ROUND='NEAREST'.  */
      case ROUND_PROCDEFINED:
      case ROUND_UNSPECIFIED:
      case ROUND_ZERO: /* Do nothing and truncation occurs.  */

I think it is wrong to handle ROUND_PROCDEFINED and ROUND_UNSPECIFIED as
ROUND_ZERO.



More information about the Gcc-bugs mailing list