changeset 8465:a33d54e4e24f

Fix a portability problem on x86.
author Bruno Haible <bruno@clisp.org>
date Sat, 17 Mar 2007 20:07:01 +0000
parents 2caaf6f17c1d
children c9b54316f274
files ChangeLog lib/vasnprintf.c
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-03-17  Bruno Haible  <bruno@clisp.org>
+
+	* lib/vasnprintf.c (VASNPRINTF): Clear out the memory used for arg_mem
+	before comparing it. Needed because on some platforms (e.g. x86) a
+	'long double' occupies less bytes than sizeof (long double).
+
 2007-03-17  Bruno Haible  <bruno@clisp.org>
 
 	* tests/test-crc.c (main): Make printf statements 64-bit clean.
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -419,7 +419,9 @@
 			  {
 			    /* Distinguish 0.0L and -0.0L.  */
 			    static long double plus_zero = 0.0L;
-			    long double arg_mem = arg;
+			    long double arg_mem;
+			    memset (&arg_mem, 0, sizeof (long double));
+			    arg_mem = arg;
 			    if (memcmp (&plus_zero, &arg_mem, sizeof (long double)) != 0)
 			      {
 				sign = -1;
@@ -567,7 +569,9 @@
 			  {
 			    /* Distinguish 0.0 and -0.0.  */
 			    static double plus_zero = 0.0;
-			    double arg_mem = arg;
+			    double arg_mem;
+			    memset (&arg_mem, 0, sizeof (double));
+			    arg_mem = arg;
 			    if (memcmp (&plus_zero, &arg_mem, sizeof (double)) != 0)
 			      {
 				sign = -1;