This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, libquadmath] PR47293 NAN not correctly read
On 01/27/2011 11:42 AM, Jakub Jelinek wrote:
On Wed, Jan 26, 2011 at 07:43:51PM -0800, Jerry DeLisle wrote:
This patch is simple. The bit pattern for NAN was mixed up.
1) It should be 0x7fff8000 instead of 0xffff8000
2) the code will handle endianess incorrectly
case STRTOG_NaN:
L[0] = ld_QNAN0;
L[1] = ld_QNAN1;
L[2] = ld_QNAN2;
L[3] = ld_QNAN3;
should be
L[_3] = ld_QNAN0;
L[_2] = ld_QNAN1;
L[_1] = ld_QNAN2;
L[_0] = ld_QNAN3;
Here is an updated patch. I will submit a change to the testsuite separately.
OK for trunk?
Jerry
Index: strtopQ.c
===================================================================
--- strtopQ.c (revision 169374)
+++ strtopQ.c (working copy)
@@ -92,10 +92,10 @@
break;
case STRTOG_NaN:
- L[0] = ld_QNAN0;
- L[1] = ld_QNAN1;
- L[2] = ld_QNAN2;
- L[3] = ld_QNAN3;
+ L[_0] = ld_QNAN3;
+ L[_1] = ld_QNAN2;
+ L[_2] = ld_QNAN1;
+ L[_3] = ld_QNAN0;
}
if (k & STRTOG_Neg)
L[_0] |= 0x80000000L;
Index: gd_qnan.h
===================================================================
--- gd_qnan.h (revision 169374)
+++ gd_qnan.h (working copy)
@@ -1,12 +1,12 @@
-#define f_QNAN 0xffc00000
+#define f_QNAN 0x7fc00000
#define d_QNAN0 0x0
-#define d_QNAN1 0xfff80000
+#define d_QNAN1 0x7ff80000
#define ld_QNAN0 0x0
-#define ld_QNAN1 0xc0000000
-#define ld_QNAN2 0xffff
-#define ld_QNAN3 0x0
+#define ld_QNAN1 0x0
+#define ld_QNAN2 0x0
+#define ld_QNAN3 0x7fff8000
#define ldus_QNAN0 0x0
#define ldus_QNAN1 0x0
#define ldus_QNAN2 0x0
#define ldus_QNAN3 0xc000
-#define ldus_QNAN4 0xffff
+#define ldus_QNAN4 0x7fff