From c3c8fb8fd5880613c2aa14bae661652b3610eadd Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 17 Mar 2007 20:07:01 +0000 Subject: [PATCH] Fix a portability problem on x86. --- ChangeLog | 6 ++++++ lib/vasnprintf.c | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 985a34be51..9902b25188 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-03-17 Bruno Haible + + * 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 * tests/test-crc.c (main): Make printf statements 64-bit clean. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 34d2a46876..b13dbd5ee1 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -419,7 +419,9 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar { /* 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 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar { /* 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; -- 2.30.2