https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93727

--- Comment #30 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
A minor adjustment:

diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 1bad5c49531..af75738c436 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1976,7 +1976,7 @@ write_ex (st_parameter_dt *dtp, const fnode *f, const
char *p, int kind)
   /* Format the exponent field with specified width 'e'. The 'e' parameter
      is the total exponent width INCLUDING 'P' and the sign.  */

-  int exp_digits = e - 2;  /* Subtract 'P' and sign character */
+  int exp_digits = e;
   if (exp_digits < 1)
     exp_digits = 1;  /* Minimum 1 digit */

I was thinking e is a width. No, it is the number of exponent digits requested
by the user.

I have the two test cases in the patch corrected now.

I need to review the standard regarding rounding of hex digits if a user
specifies a width too narrow.

Reply via email to