aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorDominique d'Humieres <dhumieres.dominique@free.fr>2020-07-24 20:07:12 +0200
committerThomas Koenig <tkoenig@gcc.gnu.org>2020-07-24 20:47:30 +0200
commit05e0971bcf94a481cbfa2731484f024a67dbd4a5 (patch)
treeda424021adbb7e0e14a969f638ee6cb42b02cfd6 /libgfortran/io
parent048ba9c02db7ee461abe86a37544fcd4e0cf8858 (diff)
downloadgcc-05e0971bcf94a481cbfa2731484f024a67dbd4a5.zip
gcc-05e0971bcf94a481cbfa2731484f024a67dbd4a5.tar.gz
gcc-05e0971bcf94a481cbfa2731484f024a67dbd4a5.tar.bz2
PR 93592 - Invalid UP/DOWN rounding with EN descriptor.
The fix is obvious (I have added a comment). The tests are probably an overkill, but it does not hurt. libgfortran/ChangeLog: PR fortran/93592 * io/write_float.def (build_float_string): Do not reset nbefore for FMT_F and FMT_EN. gcc/testsuite/ChangeLog: PR fortran/93592 * gfortran.dg/fmt_en.f90: Adjust test. * gfortran.dg/fmt_en_rd.f90: New test. * gfortran.dg/fmt_en_rn.f90: New test. * gfortran.dg/fmt_en_ru.f90: New test. * gfortran.dg/fmt_en_rz.f90: New test.
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/write_float.def3
1 files changed, 2 insertions, 1 deletions
diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def
index 8a1be05..3311db3 100644
--- a/libgfortran/io/write_float.def
+++ b/libgfortran/io/write_float.def
@@ -399,7 +399,8 @@ build_float_string (st_parameter_dt *dtp, const fnode *f, char *buffer,
updown:
rchar = '0';
- if (ft != FMT_F && w > 0 && d == 0 && p == 0)
+ /* Do not reset nbefore for FMT_F and FMT_EN. */
+ if (ft != FMT_F && ft !=FMT_EN && w > 0 && d == 0 && p == 0)
nbefore = 1;
/* Scan for trailing zeros to see if we really need to round it. */
for(i = nbefore + nafter; i < ndigits; i++)