* [Patch] libgfortran: write_float bug
@ 2004-07-07 9:40 Andreas Krebbel
2004-07-08 21:18 ` Paul Brook
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Krebbel @ 2004-07-07 9:40 UTC (permalink / raw)
To: gcc-patches; +Cc: fortran
Hello,
on s390 the nan_inf_fmt.f90 testcase in the
libgfortran.fortran-torture testsuite fails due to a missing length
check in io/write.c:write_float.
The attached patch adds the necessary check.
I think the patch can be considered obvious, so I didn't bootstrap
gcc.
OK?
Bye
-Andreas-
2004-07-07 Andreas Krebbel <krebbel1@de.ibm.com>
* libgfortran/io/write.c: (write_float): Added length check.
Index: libgfortran/io/write.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/write.c,v
retrieving revision 1.7
diff -p -c -r1.7 write.c
*** libgfortran/io/write.c 28 Jun 2004 01:30:26 -0000 1.7
--- libgfortran/io/write.c 7 Jul 2004 08:55:30 -0000
*************** write_float (fnode *f, const char *sourc
*** 535,541 ****
memcpy(p + nb - 8, "Infinity", 8);
else
memcpy(p + nb - 3, "Inf", 3);
! if (nb < 8)
memset(p + nb - 4, fin, 1);
else if (nb > 8)
memset(p + nb - 9, fin, 1);
--- 535,541 ----
memcpy(p + nb - 8, "Infinity", 8);
else
memcpy(p + nb - 3, "Inf", 3);
! if (nb < 8 && nb > 3)
memset(p + nb - 4, fin, 1);
else if (nb > 8)
memset(p + nb - 9, fin, 1);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch] libgfortran: write_float bug
2004-07-07 9:40 [Patch] libgfortran: write_float bug Andreas Krebbel
@ 2004-07-08 21:18 ` Paul Brook
0 siblings, 0 replies; 2+ messages in thread
From: Paul Brook @ 2004-07-08 21:18 UTC (permalink / raw)
To: fortran; +Cc: Andreas Krebbel, gcc-patches
> 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-07-08 19:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-07 9:40 [Patch] libgfortran: write_float bug Andreas Krebbel
2004-07-08 21:18 ` Paul Brook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).