summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2008-08-01 11:30:27 +0200
committerBruno Haible <bruno@clisp.org>2008-08-01 11:30:27 +0200
commit4eb59b32a2a687c113f3c0dfc166fc2573acb84f (patch)
treec4ca32c05616fdb00eaef4ea878fbef0f7c7bab3 /tests
parent3054279c0cca4c1f9c61997f924685b1d70c2353 (diff)
downloadgnulib-4eb59b32a2a687c113f3c0dfc166fc2573acb84f.tar.gz
Work around bug of HP-UX 10.20 cc with -0.0 literal.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-ceilf1.c6
-rw-r--r--tests/test-ceill.c6
-rw-r--r--tests/test-floorf1.c6
-rw-r--r--tests/test-floorl.c6
-rw-r--r--tests/test-frexp.c6
-rw-r--r--tests/test-frexpl.c6
-rw-r--r--tests/test-isnan.c18
-rw-r--r--tests/test-isnand.h6
-rw-r--r--tests/test-isnanf.h6
-rw-r--r--tests/test-isnanl.h6
-rw-r--r--tests/test-ldexpl.c6
-rw-r--r--tests/test-round1.c6
-rw-r--r--tests/test-roundf1.c6
-rw-r--r--tests/test-roundl.c6
-rw-r--r--tests/test-signbit.c12
-rw-r--r--tests/test-snprintf-posix.h30
-rw-r--r--tests/test-sprintf-posix.h30
-rw-r--r--tests/test-strtod.c12
-rw-r--r--tests/test-trunc1.c6
-rw-r--r--tests/test-truncf1.c6
-rw-r--r--tests/test-truncl.c6
-rw-r--r--tests/test-vasnprintf-posix.c30
-rw-r--r--tests/test-vasprintf-posix.c30
23 files changed, 185 insertions, 73 deletions
diff --git a/tests/test-ceilf1.c b/tests/test-ceilf1.c
index f17c19afb3..8931a62afc 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 5701246c21..80ff75ba66 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 b9c4da4d62..e15b293b8f 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 8f10f4e4fd..49cc8c2517 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 5d950631e1..0cd08230be 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 08042be4a1..a91afce46b 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 9761ee662f..ed3e827513 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 cf8cb5d4ba..09c5e97768 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 7f6eb1219e..f3f387c4b1 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 99d624bff6..d89719031d 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 9f3de0298b..322c063581 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 935eb10473..0f2ed94af0 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 60e19465eb..159762ee06 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 552d4f5266..ae4d3464b2 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 2245e02445..30ba1b07e4 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 47ad86c4be..1134d80b58 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 8e8539ad5b..5beadca664 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 704dc1e36e..d99e5fe5ec 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 ebe4482122..b9e8a3c88a 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 8d468403c2..a9abed4432 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 dd2a9c1f0b..3ea856a994 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 895c807c7c..42d9267cda 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 bd9039f5a2..e75e15d386 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);