From 4eb59b32a2a687c113f3c0dfc166fc2573acb84f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 1 Aug 2008 11:30:27 +0200 Subject: [PATCH] Work around bug of HP-UX 10.20 cc with -0.0 literal. --- ChangeLog | 57 +++++++++++++++++++++++++++++++++++++++++++ tests/test-ceilf1.c | 6 ++++- tests/test-ceill.c | 6 ++++- tests/test-floorf1.c | 6 ++++- tests/test-floorl.c | 6 ++++- tests/test-frexp.c | 6 ++++- tests/test-frexpl.c | 6 ++++- tests/test-isnan.c | 18 +++++++++++--- tests/test-isnand.h | 6 ++++- tests/test-isnanf.h | 6 ++++- tests/test-isnanl.h | 6 ++++- tests/test-ldexpl.c | 6 ++++- tests/test-round1.c | 6 ++++- tests/test-roundf1.c | 6 ++++- tests/test-roundl.c | 6 ++++- tests/test-signbit.c | 12 ++++----- tests/test-snprintf-posix.h | 30 ++++++++++++++--------- tests/test-sprintf-posix.h | 30 ++++++++++++++--------- tests/test-strtod.c | 12 ++++++--- tests/test-trunc1.c | 6 ++++- tests/test-truncf1.c | 6 ++++- tests/test-truncl.c | 6 ++++- tests/test-vasnprintf-posix.c | 30 ++++++++++++++--------- tests/test-vasprintf-posix.c | 30 ++++++++++++++--------- 24 files changed, 242 insertions(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3d13f184..0abbf055a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,60 @@ +2008-08-01 Bruno Haible + + Work around bug of HP-UX 10.20 cc with -0.0 literal. + * tests/test-isnanf.h (zero): New variable. + (main): Avoid literal -0.0f. + * tests/test-isnand.h (zero): New variable. + (main): Avoid literal -0.0. + * tests/test-isnanl.h (zero): New variable. + (main): Avoid literal -0.0L. + * tests/test-isnan.c (zerof, zerod, zerol): New variables. + (test_float, test_double, test_long_double): Avoid literals -0.0f, + -0.0, -0.0L. + * tests/test-signbit.c (test_signbitf): Avoid literal -0.0f. + (test_signbitd): Avoid literal -0.0. + (test_signbitl): Avoid literal -0.0L. + * tests/test-ceilf1.c (zero): New variable. + (main): Avoid literal -0.0f. + * tests/test-ceill.c (zero): New variable. + (main): Avoid literal -0.0L. + * tests/test-floorf1.c (zero): New variable. + (main): Avoid literal -0.0f. + * tests/test-floorl.c (zero): New variable. + (main): Avoid literal -0.0L. + * tests/test-roundf1.c (zero): New variable. + (main): Avoid literal -0.0f. + * tests/test-round1.c (zero): New variable. + (main): Avoid literal -0.0. + * tests/test-roundl.c (zero): New variable. + (main): Avoid literal -0.0L. + * tests/test-truncf1.c (zero): New variable. + (main): Avoid literal -0.0f. + * tests/test-trunc1.c (zero): New variable. + (main): Avoid literal -0.0. + * tests/test-truncl.c (zero): New variable. + (main): Avoid literal -0.0L. + * tests/test-frexp.c (zero): New variable. + (main): Avoid literal -0.0. + * tests/test-frexpl.c (zero): New variable. + (main): Avoid literal -0.0L. + * tests/test-ldexpl.c (zero): New variable. + (main): Avoid literal -0.0L. + * tests/test-snprintf-posix.h (have_minus_zero): Avoid literal -0.0. + (zerod, zerol): New variables. + (test_function): Avoid literals -0.0, -0.0L. + * tests/test-sprintf-posix.h (have_minus_zero): Avoid literal -0.0. + (zerod, zerol): New variables. + (test_function): Avoid literals -0.0, -0.0L. + * tests/test-vasnprintf-posix.c (have_minus_zero): Avoid literal -0.0. + (zerod, zerol): New variables. + (test_function): Avoid literals -0.0, -0.0L. + * tests/test-vasprintf-posix.c (have_minus_zero): Avoid literal -0.0. + (zerod, zerol): New variables. + (test_function): Avoid literals -0.0, -0.0L. + * tests/test-strtod.c (zero): New variable. + (main): Avoid literal -0.0. + Reported by Jonathan C. Patschke . + 2008-07-31 Jim Meyering sha256.h: correct definition of SHA224_DIGEST_SIZE diff --git a/tests/test-ceilf1.c b/tests/test-ceilf1.c index f17c19afb..8931a62af 100644 --- a/tests/test-ceilf1.c +++ b/tests/test-ceilf1.c @@ -38,12 +38,16 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. + So we use -zero instead. */ +float zero = 0.0f; + int main () { /* Zero. */ ASSERT (ceilf (0.0f) == 0.0f); - ASSERT (ceilf (-0.0f) == 0.0f); + ASSERT (ceilf (-zero) == 0.0f); /* Positive numbers. */ ASSERT (ceilf (0.3f) == 1.0f); ASSERT (ceilf (0.7f) == 1.0f); diff --git a/tests/test-ceill.c b/tests/test-ceill.c index 5701246c2..80ff75ba6 100644 --- a/tests/test-ceill.c +++ b/tests/test-ceill.c @@ -38,6 +38,10 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zero = 0.0L; + int main () { @@ -47,7 +51,7 @@ main () /* Zero. */ ASSERT (ceill (0.0L) == 0.0L); - ASSERT (ceill (-0.0L) == 0.0L); + ASSERT (ceill (-zero) == 0.0L); /* Positive numbers. */ ASSERT (ceill (0.3L) == 1.0L); ASSERT (ceill (0.7L) == 1.0L); diff --git a/tests/test-floorf1.c b/tests/test-floorf1.c index b9c4da4d6..e15b293b8 100644 --- a/tests/test-floorf1.c +++ b/tests/test-floorf1.c @@ -38,12 +38,16 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. + So we use -zero instead. */ +float zero = 0.0f; + int main () { /* Zero. */ ASSERT (floorf (0.0f) == 0.0f); - ASSERT (floorf (-0.0f) == 0.0f); + ASSERT (floorf (-zero) == 0.0f); /* Positive numbers. */ ASSERT (floorf (0.3f) == 0.0f); ASSERT (floorf (0.7f) == 0.0f); diff --git a/tests/test-floorl.c b/tests/test-floorl.c index 8f10f4e4f..49cc8c251 100644 --- a/tests/test-floorl.c +++ b/tests/test-floorl.c @@ -38,6 +38,10 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zero = 0.0L; + int main () { @@ -47,7 +51,7 @@ main () /* Zero. */ ASSERT (floorl (0.0L) == 0.0L); - ASSERT (floorl (-0.0L) == 0.0L); + ASSERT (floorl (-zero) == 0.0L); /* Positive numbers. */ ASSERT (floorl (0.3L) == 0.0L); ASSERT (floorl (0.7L) == 0.0L); diff --git a/tests/test-frexp.c b/tests/test-frexp.c index 5d950631e..0cd08230b 100644 --- a/tests/test-frexp.c +++ b/tests/test-frexp.c @@ -44,6 +44,10 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zero = 0.0; + static double my_ldexp (double x, int d) { @@ -102,7 +106,7 @@ main () { /* Negative zero. */ int exp = -9999; double mantissa; - x = -0.0; + x = -zero; mantissa = frexp (x, &exp); ASSERT (exp == 0); ASSERT (mantissa == x); diff --git a/tests/test-frexpl.c b/tests/test-frexpl.c index 08042be4a..a91afce46 100644 --- a/tests/test-frexpl.c +++ b/tests/test-frexpl.c @@ -57,6 +57,10 @@ # define MIN_NORMAL_EXP LDBL_MIN_EXP #endif +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zero = 0.0L; + static long double my_ldexp (long double x, int d) { @@ -113,7 +117,7 @@ main () { /* Negative zero. */ int exp = -9999; long double mantissa; - x = -0.0L; + x = -zero; mantissa = frexpl (x, &exp); ASSERT (exp == 0); ASSERT (mantissa == x); diff --git a/tests/test-isnan.c b/tests/test-isnan.c index 9761ee662..ed3e82751 100644 --- a/tests/test-isnan.c +++ b/tests/test-isnan.c @@ -40,6 +40,18 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. + So we use -zero instead. */ +float zerof = 0.0f; + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zerod = 0.0; + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zerol = 0.0L; + static void test_float (void) { @@ -51,7 +63,7 @@ test_float (void) ASSERT (!isnan (-2.718e30f)); ASSERT (!isnan (-2.718e-30f)); ASSERT (!isnan (0.0f)); - ASSERT (!isnan (-0.0f)); + ASSERT (!isnan (-zerof)); /* Infinite values. */ ASSERT (!isnan (1.0f / 0.0f)); ASSERT (!isnan (-1.0f / 0.0f)); @@ -91,7 +103,7 @@ test_double (void) ASSERT (!isnan (-2.718e30)); ASSERT (!isnan (-2.718e-30)); ASSERT (!isnan (0.0)); - ASSERT (!isnan (-0.0)); + ASSERT (!isnan (-zerod)); /* Infinite values. */ ASSERT (!isnan (1.0 / 0.0)); ASSERT (!isnan (-1.0 / 0.0)); @@ -134,7 +146,7 @@ test_long_double (void) ASSERT (!isnan (-2.718e30L)); ASSERT (!isnan (-2.718e-30L)); ASSERT (!isnan (0.0L)); - ASSERT (!isnan (-0.0L)); + ASSERT (!isnan (-zerol)); /* Infinite values. */ ASSERT (!isnan (1.0L / 0.0L)); ASSERT (!isnan (-1.0L / 0.0L)); diff --git a/tests/test-isnand.h b/tests/test-isnand.h index cf8cb5d4b..09c5e9776 100644 --- a/tests/test-isnand.h +++ b/tests/test-isnand.h @@ -34,6 +34,10 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zero = 0.0; + int main () { @@ -45,7 +49,7 @@ main () ASSERT (!isnand (-2.718e30)); ASSERT (!isnand (-2.718e-30)); ASSERT (!isnand (0.0)); - ASSERT (!isnand (-0.0)); + ASSERT (!isnand (-zero)); /* Infinite values. */ ASSERT (!isnand (1.0 / 0.0)); ASSERT (!isnand (-1.0 / 0.0)); diff --git a/tests/test-isnanf.h b/tests/test-isnanf.h index 7f6eb1219..f3f387c4b 100644 --- a/tests/test-isnanf.h +++ b/tests/test-isnanf.h @@ -34,6 +34,10 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. + So we use -zero instead. */ +float zero = 0.0f; + int main () { @@ -45,7 +49,7 @@ main () ASSERT (!isnanf (-2.718e30f)); ASSERT (!isnanf (-2.718e-30f)); ASSERT (!isnanf (0.0f)); - ASSERT (!isnanf (-0.0f)); + ASSERT (!isnanf (-zero)); /* Infinite values. */ ASSERT (!isnanf (1.0f / 0.0f)); ASSERT (!isnanf (-1.0f / 0.0f)); diff --git a/tests/test-isnanl.h b/tests/test-isnanl.h index 99d624bff..d89719031 100644 --- a/tests/test-isnanl.h +++ b/tests/test-isnanl.h @@ -33,6 +33,10 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zero = 0.0L; + int main () { @@ -49,7 +53,7 @@ main () ASSERT (!isnanl (-2.718e30L)); ASSERT (!isnanl (-2.718e-30L)); ASSERT (!isnanl (0.0L)); - ASSERT (!isnanl (-0.0L)); + ASSERT (!isnanl (-zero)); /* Infinite values. */ ASSERT (!isnanl (1.0L / 0.0L)); ASSERT (!isnanl (-1.0L / 0.0L)); diff --git a/tests/test-ldexpl.c b/tests/test-ldexpl.c index 9f3de0298..322c06358 100644 --- a/tests/test-ldexpl.c +++ b/tests/test-ldexpl.c @@ -39,6 +39,10 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zero = 0.0L; + int main () { @@ -78,7 +82,7 @@ main () } { /* Negative zero. */ - x = -0.0L; + x = -zero; y = ldexpl (x, 0); ASSERT (y == x); ASSERT (signbit (x)); y = ldexpl (x, 5); ASSERT (y == x); ASSERT (signbit (x)); y = ldexpl (x, -5); ASSERT (y == x); ASSERT (signbit (x)); diff --git a/tests/test-round1.c b/tests/test-round1.c index 935eb1047..0f2ed94af 100644 --- a/tests/test-round1.c +++ b/tests/test-round1.c @@ -40,12 +40,16 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zero = 0.0; + int main () { /* Zero. */ ASSERT (round (0.0) == 0.0); - ASSERT (round (-0.0) == 0.0); + ASSERT (round (-zero) == 0.0); /* Positive numbers. */ ASSERT (round (0.3) == 0.0); ASSERT (round (0.5) == 1.0); diff --git a/tests/test-roundf1.c b/tests/test-roundf1.c index 60e19465e..159762ee0 100644 --- a/tests/test-roundf1.c +++ b/tests/test-roundf1.c @@ -40,12 +40,16 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. + So we use -zero instead. */ +float zero = 0.0f; + int main () { /* Zero. */ ASSERT (roundf (0.0f) == 0.0f); - ASSERT (roundf (-0.0f) == 0.0f); + ASSERT (roundf (-zero) == 0.0f); /* Positive numbers. */ ASSERT (roundf (0.3f) == 0.0f); ASSERT (roundf (0.5f) == 1.0f); diff --git a/tests/test-roundl.c b/tests/test-roundl.c index 552d4f526..ae4d3464b 100644 --- a/tests/test-roundl.c +++ b/tests/test-roundl.c @@ -40,6 +40,10 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zero = 0.0L; + int main () { @@ -49,7 +53,7 @@ main () /* Zero. */ ASSERT (roundl (0.0L) == 0.0L); - ASSERT (roundl (-0.0L) == 0.0L); + ASSERT (roundl (-zero) == 0.0L); /* Positive numbers. */ ASSERT (roundl (0.3L) == 0.0L); ASSERT (roundl (0.5L) == 1.0L); diff --git a/tests/test-signbit.c b/tests/test-signbit.c index 2245e0244..30ba1b07e 100644 --- a/tests/test-signbit.c +++ b/tests/test-signbit.c @@ -56,9 +56,9 @@ test_signbitf () /* Zeros. */ ASSERT (!signbit (0.0f)); if (1.0f / -zerof < 0) - ASSERT (signbit (-0.0f)); + ASSERT (signbit (-zerof)); else - ASSERT (!signbit (-0.0f)); + ASSERT (!signbit (-zerof)); /* Infinite values. */ ASSERT (!signbit (1.0f / 0.0f)); ASSERT (signbit (-1.0f / 0.0f)); @@ -101,9 +101,9 @@ test_signbitd () /* Zeros. */ ASSERT (!signbit (0.0)); if (1.0 / -zerod < 0) - ASSERT (signbit (-0.0)); + ASSERT (signbit (-zerod)); else - ASSERT (!signbit (-0.0)); + ASSERT (!signbit (-zerod)); /* Infinite values. */ ASSERT (!signbit (1.0 / 0.0)); ASSERT (signbit (-1.0 / 0.0)); @@ -144,9 +144,9 @@ test_signbitl () /* Zeros. */ ASSERT (!signbit (0.0L)); if (1.0L / minus_zerol < 0) - ASSERT (signbit (-0.0L)); + ASSERT (signbit (-zerol)); else - ASSERT (!signbit (-0.0L)); + ASSERT (!signbit (-zerol)); /* Infinite values. */ ASSERT (!signbit (1.0L / 0.0L)); ASSERT (signbit (-1.0L / 0.0L)); diff --git a/tests/test-snprintf-posix.h b/tests/test-snprintf-posix.h index 47ad86c4b..1134d80b5 100644 --- a/tests/test-snprintf-posix.h +++ b/tests/test-snprintf-posix.h @@ -23,10 +23,18 @@ static int have_minus_zero () { static double plus_zero = 0.0; - static double minus_zero = -0.0; + double minus_zero = - plus_zero; return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; } +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zerod = 0.0; + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zerol = 0.0L; + /* Representation of an 80-bit 'long double' as an initializer for a sequence of 'unsigned int' words. */ #ifdef WORDS_BIGENDIAN @@ -172,7 +180,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%a %d", -0.0, 33, 44, 55); + my_snprintf (result, sizeof (result), "%a %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); @@ -436,7 +444,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%La %d", -0.0L, 33, 44, 55); + my_snprintf (result, sizeof (result), "%La %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); @@ -881,7 +889,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%f %d", -0.0, 33, 44, 55); + my_snprintf (result, sizeof (result), "%f %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1144,7 +1152,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%Lf %d", -0.0L, 33, 44, 55); + my_snprintf (result, sizeof (result), "%Lf %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1407,7 +1415,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%F %d", -0.0, 33, 44, 55); + my_snprintf (result, sizeof (result), "%F %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1517,7 +1525,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%LF %d", -0.0L, 33, 44, 55); + my_snprintf (result, sizeof (result), "%LF %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1731,7 +1739,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%e %d", -0.0, 33, 44, 55); + my_snprintf (result, sizeof (result), "%e %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0 || strcmp (result, "-0.000000e+000 33") == 0); @@ -2008,7 +2016,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%Le %d", -0.0L, 33, 44, 55); + my_snprintf (result, sizeof (result), "%Le %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0); ASSERT (retval == strlen (result)); @@ -2372,7 +2380,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%g %d", -0.0, 33, 44, 55); + my_snprintf (result, sizeof (result), "%g %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); @@ -2639,7 +2647,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) { /* Negative zero. */ char result[100]; int retval = - my_snprintf (result, sizeof (result), "%Lg %d", -0.0L, 33, 44, 55); + my_snprintf (result, sizeof (result), "%Lg %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); diff --git a/tests/test-sprintf-posix.h b/tests/test-sprintf-posix.h index 8e8539ad5..5beadca66 100644 --- a/tests/test-sprintf-posix.h +++ b/tests/test-sprintf-posix.h @@ -23,10 +23,18 @@ static int have_minus_zero () { static double plus_zero = 0.0; - static double minus_zero = -0.0; + double minus_zero = - plus_zero; return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; } +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zerod = 0.0; + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zerol = 0.0L; + /* Representation of an 80-bit 'long double' as an initializer for a sequence of 'unsigned int' words. */ #ifdef WORDS_BIGENDIAN @@ -158,7 +166,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%a %d", -0.0, 33, 44, 55); + my_sprintf (result, "%a %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); @@ -422,7 +430,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%La %d", -0.0L, 33, 44, 55); + my_sprintf (result, "%La %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); @@ -867,7 +875,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%f %d", -0.0, 33, 44, 55); + my_sprintf (result, "%f %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1124,7 +1132,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%Lf %d", -0.0L, 33, 44, 55); + my_sprintf (result, "%Lf %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1381,7 +1389,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%F %d", -0.0, 33, 44, 55); + my_sprintf (result, "%F %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1491,7 +1499,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%LF %d", -0.0L, 33, 44, 55); + my_sprintf (result, "%LF %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); @@ -1705,7 +1713,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%e %d", -0.0, 33, 44, 55); + my_sprintf (result, "%e %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0 || strcmp (result, "-0.000000e+000 33") == 0); @@ -1982,7 +1990,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%Le %d", -0.0L, 33, 44, 55); + my_sprintf (result, "%Le %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0); ASSERT (retval == strlen (result)); @@ -2346,7 +2354,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%g %d", -0.0, 33, 44, 55); + my_sprintf (result, "%g %d", -zerod, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); @@ -2613,7 +2621,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* Negative zero. */ char result[1000]; int retval = - my_sprintf (result, "%Lg %d", -0.0L, 33, 44, 55); + my_sprintf (result, "%Lg %d", -zerol, 33, 44, 55); if (have_minus_zero ()) ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); diff --git a/tests/test-strtod.c b/tests/test-strtod.c index 704dc1e36..d99e5fe5e 100644 --- a/tests/test-strtod.c +++ b/tests/test-strtod.c @@ -42,6 +42,10 @@ /* Avoid requiring -lm just for fabs. */ #define FABS(d) ((d) < 0.0 ? -(d) : (d)) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zero = 0.0; + int main () { @@ -317,7 +321,7 @@ main () errno = 0; result = strtod (input, &ptr); ASSERT (result == 0.0); - ASSERT (!!signbit (result) == !!signbit (-0.0)); /* IRIX 6.5, OSF/1 4.0 */ + ASSERT (!!signbit (result) == !!signbit (-zero)); /* IRIX 6.5, OSF/1 4.0 */ ASSERT (ptr == input + 2); ASSERT (errno == 0); } @@ -412,7 +416,7 @@ main () errno = 0; result = strtod (input, &ptr); ASSERT (result == 0.0); - ASSERT (!!signbit (result) == !!signbit (-0.0)); /* MacOS X 10.3, FreeBSD 6.2, IRIX 6.5, OSF/1 4.0 */ + ASSERT (!!signbit (result) == !!signbit (-zero)); /* MacOS X 10.3, FreeBSD 6.2, IRIX 6.5, OSF/1 4.0 */ ASSERT (ptr == input + 2); /* glibc-2.3.6, MacOS X 10.3, FreeBSD 6.2 */ ASSERT (errno == 0); } @@ -537,7 +541,7 @@ main () 0 on negative underflow, even though quality of implementation demands preserving the sign. Disable this test until fixed glibc is more prevalent. */ - ASSERT (!!signbit (result) == !!signbit (-0.0)); /* glibc-2.3.6, mingw */ + ASSERT (!!signbit (result) == !!signbit (-zero)); /* glibc-2.3.6, mingw */ #endif ASSERT (ptr == input + 10); ASSERT (errno == ERANGE); @@ -906,7 +910,7 @@ main () errno = 0; result = strtod (input, &ptr); ASSERT (result == 0.0); - ASSERT (!!signbit (result) == !!signbit (-0.0)); /* IRIX 6.5, OSF/1 4.0 */ + ASSERT (!!signbit (result) == !!signbit (-zero)); /* IRIX 6.5, OSF/1 4.0 */ ASSERT (ptr == input + m); ASSERT (errno == 0); } diff --git a/tests/test-trunc1.c b/tests/test-trunc1.c index ebe448212..b9e8a3c88 100644 --- a/tests/test-trunc1.c +++ b/tests/test-trunc1.c @@ -38,12 +38,16 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zero = 0.0; + int main () { /* Zero. */ ASSERT (trunc (0.0) == 0.0); - ASSERT (trunc (-0.0) == 0.0); + ASSERT (trunc (-zero) == 0.0); /* Positive numbers. */ ASSERT (trunc (0.3) == 0.0); ASSERT (trunc (0.7) == 0.0); diff --git a/tests/test-truncf1.c b/tests/test-truncf1.c index 8d468403c..a9abed443 100644 --- a/tests/test-truncf1.c +++ b/tests/test-truncf1.c @@ -38,12 +38,16 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f. + So we use -zero instead. */ +float zero = 0.0f; + int main () { /* Zero. */ ASSERT (truncf (0.0f) == 0.0f); - ASSERT (truncf (-0.0f) == 0.0f); + ASSERT (truncf (-zero) == 0.0f); /* Positive numbers. */ ASSERT (truncf (0.3f) == 0.0f); ASSERT (truncf (0.7f) == 0.0f); diff --git a/tests/test-truncl.c b/tests/test-truncl.c index dd2a9c1f0..3ea856a99 100644 --- a/tests/test-truncl.c +++ b/tests/test-truncl.c @@ -38,6 +38,10 @@ } \ while (0) +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zero = 0.0L; + int main () { @@ -47,7 +51,7 @@ main () /* Zero. */ ASSERT (truncl (0.0L) == 0.0L); - ASSERT (truncl (-0.0L) == 0.0L); + ASSERT (truncl (-zero) == 0.0L); /* Positive numbers. */ ASSERT (truncl (0.3L) == 0.0L); ASSERT (truncl (0.7L) == 0.0L); diff --git a/tests/test-vasnprintf-posix.c b/tests/test-vasnprintf-posix.c index 895c807c7..42d9267cd 100644 --- a/tests/test-vasnprintf-posix.c +++ b/tests/test-vasnprintf-posix.c @@ -48,10 +48,18 @@ static int have_minus_zero () { static double plus_zero = 0.0; - static double minus_zero = -0.0; + double minus_zero = - plus_zero; return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; } +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zerod = 0.0; + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zerol = 0.0L; + /* Representation of an 80-bit 'long double' as an initializer for a sequence of 'unsigned int' words. */ #ifdef WORDS_BIGENDIAN @@ -217,7 +225,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%a %d", -0.0, 33, 44, 55); + my_asnprintf (NULL, &length, "%a %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0x0p+0 33") == 0); @@ -531,7 +539,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%La %d", -0.0L, 33, 44, 55); + my_asnprintf (NULL, &length, "%La %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0x0p+0 33") == 0); @@ -1044,7 +1052,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%f %d", -0.0, 33, 44, 55); + my_asnprintf (NULL, &length, "%f %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); @@ -1343,7 +1351,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%Lf %d", -0.0L, 33, 44, 55); + my_asnprintf (NULL, &length, "%Lf %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); @@ -1654,7 +1662,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%F %d", -0.0, 33, 44, 55); + my_asnprintf (NULL, &length, "%F %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); @@ -1790,7 +1798,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%LF %d", -0.0L, 33, 44, 55); + my_asnprintf (NULL, &length, "%LF %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); @@ -2031,7 +2039,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%e %d", -0.0, 33, 44, 55); + my_asnprintf (NULL, &length, "%e %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0 @@ -2352,7 +2360,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%Le %d", -0.0L, 33, 44, 55); + my_asnprintf (NULL, &length, "%Le %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0); @@ -2774,7 +2782,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%g %d", -0.0, 33, 44, 55); + my_asnprintf (NULL, &length, "%g %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0 33") == 0); @@ -3085,7 +3093,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Negative zero. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%Lg %d", -0.0L, 33, 44, 55); + my_asnprintf (NULL, &length, "%Lg %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0 33") == 0); diff --git a/tests/test-vasprintf-posix.c b/tests/test-vasprintf-posix.c index bd9039f5a..e75e15d38 100644 --- a/tests/test-vasprintf-posix.c +++ b/tests/test-vasprintf-posix.c @@ -48,10 +48,18 @@ static int have_minus_zero () { static double plus_zero = 0.0; - static double minus_zero = -0.0; + double minus_zero = - plus_zero; return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; } +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. + So we use -zero instead. */ +double zerod = 0.0; + +/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0L. + So we use -zero instead. */ +long double zerol = 0.0L; + /* Representation of an 80-bit 'long double' as an initializer for a sequence of 'unsigned int' words. */ #ifdef WORDS_BIGENDIAN @@ -198,7 +206,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%a %d", -0.0, 33, 44, 55); + my_asprintf (&result, "%a %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0x0p+0 33") == 0); @@ -512,7 +520,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%La %d", -0.0L, 33, 44, 55); + my_asprintf (&result, "%La %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0x0p+0 33") == 0); @@ -1025,7 +1033,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%f %d", -0.0, 33, 44, 55); + my_asprintf (&result, "%f %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); @@ -1324,7 +1332,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%Lf %d", -0.0L, 33, 44, 55); + my_asprintf (&result, "%Lf %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); @@ -1635,7 +1643,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%F %d", -0.0, 33, 44, 55); + my_asprintf (&result, "%F %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); @@ -1771,7 +1779,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%LF %d", -0.0L, 33, 44, 55); + my_asprintf (&result, "%LF %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000 33") == 0); @@ -2012,7 +2020,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%e %d", -0.0, 33, 44, 55); + my_asprintf (&result, "%e %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0 @@ -2333,7 +2341,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%Le %d", -0.0L, 33, 44, 55); + my_asprintf (&result, "%Le %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0.000000e+00 33") == 0); @@ -2755,7 +2763,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%g %d", -0.0, 33, 44, 55); + my_asprintf (&result, "%g %d", -zerod, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0 33") == 0); @@ -3066,7 +3074,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) { /* Negative zero. */ char *result; int retval = - my_asprintf (&result, "%Lg %d", -0.0L, 33, 44, 55); + my_asprintf (&result, "%Lg %d", -zerol, 33, 44, 55); ASSERT (result != NULL); if (have_minus_zero ()) ASSERT (strcmp (result, "-0 33") == 0); -- 2.11.0