This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gfortran] PATCH formatted write of 0.0 (PR libfortran/20101)
- From: FX Coudert <Francois-Xavier dot Coudert at lcp dot u-psud dot fr>
- To: Tobias SchlÃter <tobias dot schlueter at physik dot uni-muenchen dot de>
- Cc: GCC Fortran mailing list <fortran at gcc dot gnu dot org>,gcc-patches at gcc dot gnu dot org
- Date: Sun, 27 Feb 2005 18:07:10 +0100
- Subject: Re: [gfortran] PATCH formatted write of 0.0 (PR libfortran/20101)
- Organization: Laboratoire de Chimie Physique
- References: <4221ECB6.7060105@lcp.u-psud.fr> <4221F6D9.4070504@physik.uni-muenchen.de>
Here is the requested testcase. I have changed the patch and Changelog
entry since you already committed the fix for the typo. Here are the two
Changelog entries for the fix to libgfortran (pr20101.diff) and testcase
(write_0_pe_format.f90).
2005-02-27 FranÃois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20101
* write.c (output_float): Adding special check for value 0.0 in
PE format.
2005-02-27 FranÃois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20101
* gfortran.dg/write_0_pe_format.f90: New test.
Index: libgfortran/io/write.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/write.c,v
retrieving revision 1.23
diff -u -p -r1.23 write.c
@@ -375,7 +380,8 @@ output_float (fnode *f, double value, in
case FMT_E:
case FMT_D:
i = g.scale_factor;
- e -= i;
+ if (value != 0)
+ e -= i;
if (i < 0)
{
nbefore = 0;
! { dg-do run }
! PR libfortran/20101
! With format "PE", 0.0 must still have "+00" as exponent
character(len=10) :: c1, c2
write(c1,"(1pe9.2)") 0.0
write(c2,"(1pe9.2)") 1.0
if (trim(adjustl(c1)) .ne. "0.00E+00") call abort()
if (trim(adjustl(c2)) .ne. "1.00E+00") call abort()
end