This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] patch PR 20755
- From: FranÃois-Xavier Coudert <Francois-Xavier dot Coudert at lcp dot u-psud dot fr>
- To: gfortran <fortran at gcc dot gnu dot org>
- Cc: gcc-patches at gcc dot gnu dot org, dir at lanl dot gov
- Date: Tue, 05 Apr 2005 13:43:49 +0200
- Subject: [gfortran] patch PR 20755
- Organization: Laboratoire de Chimie Physique
This simple patch fixes a problem with the G format descriptor (which can
localy change the scale factor, but we forgot to restore it afterwards).
*strapped and testing in progress on i686-linux for both 4.0 and mainline.
OK if no regression showing up?
FX
2005-04-05 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20755
* write.c (write_float): A G edit descriptor may locally change
the scale factor, but it needs to be restored afterwards.
2005-04-05 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20755
* gfortran.dg/pr20755.f: New test.
Index: libgfortran/io/write.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/write.c,v
retrieving revision 1.30
diff -p -u -r1.30 write.c
--- libgfortran/io/write.c 23 Mar 2005 22:31:56 -0000 1.30
+++ libgfortran/io/write.c 5 Apr 2005 11:37:07 -0000
@@ -674,7 +674,7 @@ static void
write_float (fnode *f, const char *source, int len)
{
double n;
- int nb =0, res;
+ int nb =0, res, save_scale_factor;
char * p, fin;
fnode *f2 = NULL;
@@ -723,8 +723,10 @@ write_float (fnode *f, const char *sourc
}
else
{
+ save_scale_factor = g.scale_factor;
f2 = calculate_G_format(f, n, len, &nb);
output_float (f2, n, len);
+ g.scale_factor = save_scale_factor;
if (f2 != NULL)
free_mem(f2);
! PR libfortran/20755
! { dg-do run }
character*30 s
write (s,2000) 0.0, 0.02
if (s .ne. " 0.00 2.000E-02") call abort
write (s,2000) 0.01, 0.02
if (s .ne. " 1.000E-02 2.000E-02") call abort
2000 format (1P2G12.3)
end