This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] libgfortran: write_float bug
- From: Paul Brook <paul at codesourcery dot com>
- To: fortran at gcc dot gnu dot org
- Cc: Andreas Krebbel <krebbel1 at de dot ibm dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 8 Jul 2004 20:57:12 +0100
- Subject: Re: [Patch] libgfortran: write_float bug
- Organization: CodeSourcery
- References: <200407071109.31583.krebbel1@de.ibm.com>
> 2004-07-07 Andreas Krebbel <krebbel1@de.ibm.com>
>
> * libgfortran/io/write.c: (write_float): Added length check.
Applied, thanks.
I also changed the memset calls into direct assignments.
Index: write.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libgfortran/io/write.c,v
retrieving revision 1.7
diff -u -p -r1.7 write.c
--- write.c 28 Jun 2004 01:30:26 -0000 1.7
+++ write.c 8 Jul 2004 19:51:19 -0000
@@ -535,10 +535,10 @@ write_float (fnode *f, const char *sourc
memcpy(p + nb - 8, "Infinity", 8);
else
memcpy(p + nb - 3, "Inf", 3);
- if (nb < 8)
- memset(p + nb - 4, fin, 1);
+ if (nb < 8 && nb > 3)
+ p[nb - 4] = fin;
else if (nb > 8)
- memset(p + nb - 9, fin, 1);
+ p[nb - 9] = fin;
}
else
memcpy(p + nb - 3, "NaN", 3);