Mercurial > hg > octave-nkf > gnulib-hg
changeset 10296:06a4179ed804
Work around bug of HP-UX 10.20 cc with -0.0 literal.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 01 Aug 2008 11:30:27 +0200 |
parents | f265e54053d2 |
children | 10ed37fb2a40 |
files | ChangeLog tests/test-ceilf1.c tests/test-ceill.c tests/test-floorf1.c tests/test-floorl.c tests/test-frexp.c tests/test-frexpl.c tests/test-isnan.c tests/test-isnand.h tests/test-isnanf.h tests/test-isnanl.h tests/test-ldexpl.c tests/test-round1.c tests/test-roundf1.c tests/test-roundl.c tests/test-signbit.c tests/test-snprintf-posix.h tests/test-sprintf-posix.h tests/test-strtod.c tests/test-trunc1.c tests/test-truncf1.c tests/test-truncl.c tests/test-vasnprintf-posix.c tests/test-vasprintf-posix.c |
diffstat | 24 files changed, 242 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,60 @@ +2008-08-01 Bruno Haible <bruno@clisp.org> + + 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 <jp@centtech.com>. + 2008-07-31 Jim Meyering <meyering@redhat.com> sha256.h: correct definition of SHA224_DIGEST_SIZE
--- 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);
--- 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 @@ /* 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);
--- 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);
--- 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 @@ /* 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);
--- 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 @@ { /* Negative zero. */ int exp = -9999; double mantissa; - x = -0.0; + x = -zero; mantissa = frexp (x, &exp); ASSERT (exp == 0); ASSERT (mantissa == x);
--- 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 @@ { /* Negative zero. */ int exp = -9999; long double mantissa; - x = -0.0L; + x = -zero; mantissa = frexpl (x, &exp); ASSERT (exp == 0); ASSERT (mantissa == x);
--- 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 @@ 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 @@ 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 @@ 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));
--- 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 @@ 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));
--- 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 @@ 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));
--- 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 @@ 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));
--- 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 @@ } { /* 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));
--- 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);
--- 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);
--- 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 @@ /* 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);
--- a/tests/test-signbit.c +++ b/tests/test-signbit.c @@ -56,9 +56,9 @@ /* 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 @@ /* 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 @@ /* 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));
--- a/tests/test-snprintf-posix.h +++ b/tests/test-snprintf-posix.h @@ -23,10 +23,18 @@ 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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));
--- a/tests/test-sprintf-posix.h +++ b/tests/test-sprintf-posix.h @@ -23,10 +23,18 @@ 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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));
--- 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 @@ 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 @@ 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 @@ 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 @@ 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); }
--- 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);
--- 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);
--- 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 @@ /* 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);
--- a/tests/test-vasnprintf-posix.c +++ b/tests/test-vasnprintf-posix.c @@ -48,10 +48,18 @@ 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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);
--- a/tests/test-vasprintf-posix.c +++ b/tests/test-vasprintf-posix.c @@ -48,10 +48,18 @@ 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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 @@ { /* 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);