bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lib/regex_internal.h on 1.4.11


From: Bruno Haible
Subject: Re: lib/regex_internal.h on 1.4.11
Date: Wed, 8 Oct 2008 02:06:28 +0200
User-agent: KMail/1.5.4

Eric Blake wrote:
> > Indeed, we're in a maze of twisty little HP cc compiler bugs:
> >   <http://lists.gnu.org/archive/html/bug-gnulib/2008-04/msg00179.html>
> >   <http://lists.gnu.org/archive/html/bug-gnulib/2008-08/msg00000.html>
> 
> minus_zerol is miscompiled on at least Irix 6.2.  So until we hear
> feedback from Jonathan on what DOES allow us to compile -0.0L on
> HP-UX/hppa ...

I just happened to get access to a HP-UX 10.20 machine today. It was
installed in 1997, i.e. 11 years ago! That counts as museumware to me,
not as a reasonable portability target any more. We are putting into gnulib
code for Windows that will not work on Windows98 and WindowsME, released
in 1998 and 2000, respectively. Then why should we care about systems that
were put together in 1996 and shipped in 1997?

The test programs from
  <http://lists.gnu.org/archive/html/bug-gnulib/2008-09/msg00118.html>
yield the following results, after replacing 0.1L with LDBL_MIN (otherwise
the y may be a negative denormalized number rather than a minus zero).
The '?' mean that signbit() is not available natively on that platform.

fool.c =>
inf
0
?
0
inf
0
?
0
inf
0
?
0
-inf
1
?
1
-inf
1
?
1

food.c =>
-inf
1
?
1
-inf
1
?
0
-inf
1
?
1
-inf
1
?
1
-inf
1
?
1

So, to get a negative 'long double' zero, neither of
  long double minus_zerol = -0.0L;
  -0.0L
  -zerol
are usable. Instead, only expressions like (-0.1L * LDBL_MIN) and
(-0.1L / LDBL_MAX) work.

For 'double', the situation is more relaxed, the only form we need to
avoid is the literal -0.0; using a global variable works. (I don't want
to divide by ±0.0 to test its sign; this relies on IEEE and is outside
ISO C.)

I'm applying this:

2008-10-07  Bruno Haible  <address@hidden>

        Use a more portable replacement expression for -0.0L.
        * m4/signbit.m4 (gl_SIGNBIT_TEST_PROGRAM): Use -LDBL_MIN * LDBL_MIN
        instead of -0.0L. Fix m4 quotation.

        * tests/test-signbit.c: Include <float.h>.
        (minus_zero): New variable.
        (test_signbitl): Use minus_zero instead of -zero.
        * modules/signbit-tests (Depends-on): Add float.

        * tests/test-ceill.c: Include <float.h>.
        (zero): Remove variable.
        (minus_zero): New variable.
        (main): Use minus_zero instead of -zero.
        * modules/ceill-tests (Depends-on): Add float.

        * tests/test-floorl.c: Include <float.h>.
        (zero): Remove variable.
        (minus_zero): New variable.
        (main): Use minus_zero instead of -zero.
        * modules/floorl-tests (Depends-on): Add float.

        * tests/test-roundl.c: Include <float.h>.
        (zero): Remove variable.
        (minus_zero): New variable.
        (main): Use minus_zero instead of -zero.
        * modules/roundl-tests (Depends-on): Add float.

        * tests/test-truncl.c: Include <float.h>.
        (zero): Remove variable.
        (minus_zero): New variable.
        (main): Use minus_zero instead of -zero.
        * modules/truncl-tests (Depends-on): Add float.

        * tests/test-frexpl.c (zero): Remove variable.
        (minus_zero): New variable.
        (main): Use minus_zero instead of -zero.
        * modules/frexpl-tests (Depends-on): Add float.

        * tests/test-isnan.c (zerol): Remove variable.
        (minus_zerol): New variable.
        (test_long_double): Use minus_zerol instead of -zerol.
        * modules/isnan-tests (Depends-on): Add float.

        * tests/test-isnanl.h (zero): Remove variable.
        (minus_zero): New variable.
        (main): Use minus_zero instead of -zero.
        * modules/isnanl-nolibm-tests (Depends-on): Add float.
        * modules/isnanl-tests (Depends-on): Add float.

        * tests/test-ldexpl.c (zero): Remove variable.
        (minus_zero): New variable.
        (main): Use minus_zero instead of -zero.
        * modules/ldexpl-tests (Depends-on): Add float.

        * tests/test-snprintf-posix.h (zerol): Remove variable.
        (minus_zerol): New variable.
        (test_function): Use minus_zerol instead of -zerol.
        * modules/snprintf-posix-tests (Depends-on): Add float.
        * modules/vsnprintf-posix-tests (Depends-on): Add float.

        * tests/test-sprintf-posix.h (zerol): Remove variable.
        (minus_zerol): New variable.
        (test_function): Use minus_zerol instead of -zerol.
        * modules/sprintf-posix-tests (Depends-on): Add float.
        * modules/vsprintf-posix-tests (Depends-on): Add float.

        * tests/test-vasnprintf-posix.c (zerol): Remove variable.
        (minus_zerol): New variable.
        (test_function): Use minus_zerol instead of -zerol.
        * modules/vasnprintf-posix-tests (Depends-on): Add float.

        * tests/test-vasprintf-posix.c (zerol): Remove variable.
        (minus_zerol): New variable.
        (test_function): Use minus_zerol instead of -zerol.
        * modules/vasprintf-posix-tests (Depends-on): Add float.

--- m4/signbit.m4.orig  2008-10-08 01:48:15.000000000 +0200
+++ m4/signbit.m4       2008-10-08 01:40:20.000000000 +0200
@@ -1,4 +1,4 @@
-# signbit.m4 serial 3
+# signbit.m4 serial 4
 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -123,15 +123,21 @@
   fi
 ])
 
-AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [
+AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -p0f instead.  */
+   So we use -p0f and -p0d instead.  */
 float p0f = 0.0f;
 float m0f = -p0f;
 double p0d = 0.0;
 double m0d = -p0d;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use another constant expression instead.  */
 long double p0l = 0.0L;
+#ifdef __hpux
+long double m0l = -LDBL_MIN * LDBL_MIN;
+#else
 long double m0l = -p0l;
+#endif
 int main ()
 {
   {
@@ -169,7 +175,7 @@
   }
   return 0;
 }
-])
+]])
 
 AC_DEFUN([gl_FLOAT_SIGN_LOCATION],
 [
--- modules/ceill-tests.orig    2008-10-08 01:48:15.000000000 +0200
+++ modules/ceill-tests 2008-10-07 13:14:52.000000000 +0200
@@ -4,6 +4,7 @@
 Depends-on:
 fpucw
 isnanl-nolibm
+float
 
 configure.ac:
 
--- modules/floorl-tests.orig   2008-10-08 01:48:15.000000000 +0200
+++ modules/floorl-tests        2008-10-07 13:16:22.000000000 +0200
@@ -4,6 +4,7 @@
 Depends-on:
 fpucw
 isnanl-nolibm
+float
 
 configure.ac:
 
--- modules/frexpl-tests.orig   2008-10-08 01:48:15.000000000 +0200
+++ modules/frexpl-tests        2008-10-07 13:11:26.000000000 +0200
@@ -5,6 +5,7 @@
 fpucw
 isnanl-nolibm
 signbit
+float
 
 configure.ac:
 
--- modules/isnan-tests.orig    2008-10-08 01:48:15.000000000 +0200
+++ modules/isnan-tests 2008-10-07 13:19:19.000000000 +0200
@@ -3,6 +3,7 @@
 tests/nan.h
 
 Depends-on:
+float
 
 configure.ac:
 gl_FLOAT_EXPONENT_LOCATION
--- modules/isnanl-nolibm-tests.orig    2008-10-08 01:48:15.000000000 +0200
+++ modules/isnanl-nolibm-tests 2008-10-07 13:12:40.000000000 +0200
@@ -3,6 +3,7 @@
 tests/test-isnanl.h
 
 Depends-on:
+float
 
 configure.ac:
 gl_LONG_DOUBLE_EXPONENT_LOCATION
--- modules/isnanl-tests.orig   2008-10-08 01:48:15.000000000 +0200
+++ modules/isnanl-tests        2008-10-07 13:12:29.000000000 +0200
@@ -3,6 +3,7 @@
 tests/test-isnanl.h
 
 Depends-on:
+float
 
 configure.ac:
 gl_LONG_DOUBLE_EXPONENT_LOCATION
--- modules/ldexpl-tests.orig   2008-10-08 01:48:15.000000000 +0200
+++ modules/ldexpl-tests        2008-10-07 13:13:44.000000000 +0200
@@ -5,6 +5,7 @@
 fpucw
 isnanl-nolibm
 signbit
+float
 
 configure.ac:
 
--- modules/roundl-tests.orig   2008-10-08 01:48:15.000000000 +0200
+++ modules/roundl-tests        2008-10-07 13:16:33.000000000 +0200
@@ -4,6 +4,7 @@
 Depends-on:
 fpucw
 isnanl-nolibm
+float
 
 configure.ac:
 
--- modules/signbit-tests.orig  2008-10-08 01:48:15.000000000 +0200
+++ modules/signbit-tests       2008-10-07 13:21:32.000000000 +0200
@@ -5,6 +5,7 @@
 m4/exponentl.m4
 
 Depends-on:
+float
 
 configure.ac:
 AC_REQUIRE([gl_FLOAT_EXPONENT_LOCATION])
--- modules/snprintf-posix-tests.orig   2008-10-08 01:48:15.000000000 +0200
+++ modules/snprintf-posix-tests        2008-10-07 13:27:54.000000000 +0200
@@ -6,6 +6,7 @@
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 AC_DEFINE([CHECK_SNPRINTF_POSIX], 1,
--- modules/sprintf-posix-tests.orig    2008-10-08 01:48:15.000000000 +0200
+++ modules/sprintf-posix-tests 2008-10-07 13:29:10.000000000 +0200
@@ -5,6 +5,7 @@
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 
--- modules/truncl-tests.orig   2008-10-08 01:48:15.000000000 +0200
+++ modules/truncl-tests        2008-10-07 13:16:42.000000000 +0200
@@ -4,6 +4,7 @@
 Depends-on:
 fpucw
 isnanl-nolibm
+float
 
 configure.ac:
 
--- modules/vasnprintf-posix-tests.orig 2008-10-08 01:48:15.000000000 +0200
+++ modules/vasnprintf-posix-tests      2008-10-07 13:29:21.000000000 +0200
@@ -7,6 +7,7 @@
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 gt_LOCALE_FR
--- modules/vasprintf-posix-tests.orig  2008-10-08 01:48:16.000000000 +0200
+++ modules/vasprintf-posix-tests       2008-10-07 13:29:17.000000000 +0200
@@ -4,6 +4,7 @@
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 
--- modules/vsnprintf-posix-tests.orig  2008-10-08 01:48:16.000000000 +0200
+++ modules/vsnprintf-posix-tests       2008-10-07 13:28:04.000000000 +0200
@@ -6,6 +6,7 @@
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 AC_DEFINE([CHECK_VSNPRINTF_POSIX], 1,
--- modules/vsprintf-posix-tests.orig   2008-10-08 01:48:16.000000000 +0200
+++ modules/vsprintf-posix-tests        2008-10-07 13:29:13.000000000 +0200
@@ -5,6 +5,7 @@
 
 Depends-on:
 stdint
+float
 
 configure.ac:
 
--- tests/test-ceill.c.orig     2008-10-08 01:48:16.000000000 +0200
+++ tests/test-ceill.c  2008-10-08 01:40:24.000000000 +0200
@@ -20,6 +20,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -38,9 +39,9 @@
     }                                                                       \
   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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -51,7 +52,7 @@
 
   /* Zero.  */
   ASSERT (ceill (0.0L) == 0.0L);
-  ASSERT (ceill (-zero) == 0.0L);
+  ASSERT (ceill (minus_zero) == 0.0L);
   /* Positive numbers.  */
   ASSERT (ceill (0.3L) == 1.0L);
   ASSERT (ceill (0.7L) == 1.0L);
--- tests/test-floorl.c.orig    2008-10-08 01:48:16.000000000 +0200
+++ tests/test-floorl.c 2008-10-08 01:40:28.000000000 +0200
@@ -20,6 +20,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -38,9 +39,9 @@
     }                                                                       \
   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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -51,7 +52,7 @@
 
   /* Zero.  */
   ASSERT (floorl (0.0L) == 0.0L);
-  ASSERT (floorl (-zero) == 0.0L);
+  ASSERT (floorl (minus_zero) == 0.0L);
   /* Positive numbers.  */
   ASSERT (floorl (0.3L) == 0.0L);
   ASSERT (floorl (0.7L) == 0.0L);
--- tests/test-frexpl.c.orig    2008-10-08 01:48:16.000000000 +0200
+++ tests/test-frexpl.c 2008-10-08 01:40:31.000000000 +0200
@@ -57,9 +57,9 @@
 # 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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 static long double
 my_ldexp (long double x, int d)
@@ -117,7 +117,7 @@
   { /* Negative zero.  */
     int exp = -9999;
     long double mantissa;
-    x = -zero;
+    x = minus_zero;
     mantissa = frexpl (x, &exp);
     ASSERT (exp == 0);
     ASSERT (mantissa == x);
--- tests/test-isnan.c.orig     2008-10-08 01:48:16.000000000 +0200
+++ tests/test-isnan.c  2008-10-08 01:40:35.000000000 +0200
@@ -48,9 +48,9 @@
    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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 static void
 test_float (void)
@@ -146,7 +146,7 @@
   ASSERT (!isnan (-2.718e30L));
   ASSERT (!isnan (-2.718e-30L));
   ASSERT (!isnan (0.0L));
-  ASSERT (!isnan (-zerol));
+  ASSERT (!isnan (minus_zerol));
   /* Infinite values.  */
   ASSERT (!isnan (1.0L / 0.0L));
   ASSERT (!isnan (-1.0L / 0.0L));
--- tests/test-isnanl.h.orig    2008-10-08 01:48:16.000000000 +0200
+++ tests/test-isnanl.h 2008-10-08 01:40:38.000000000 +0200
@@ -33,9 +33,9 @@
     }                                                                       \
   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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -53,7 +53,7 @@
   ASSERT (!isnanl (-2.718e30L));
   ASSERT (!isnanl (-2.718e-30L));
   ASSERT (!isnanl (0.0L));
-  ASSERT (!isnanl (-zero));
+  ASSERT (!isnanl (minus_zero));
   /* Infinite values.  */
   ASSERT (!isnanl (1.0L / 0.0L));
   ASSERT (!isnanl (-1.0L / 0.0L));
--- tests/test-ldexpl.c.orig    2008-10-08 01:48:16.000000000 +0200
+++ tests/test-ldexpl.c 2008-10-08 01:40:41.000000000 +0200
@@ -39,9 +39,9 @@
     }                                                                       \
   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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -82,7 +82,7 @@
   }
 
   { /* Negative zero.  */
-    x = -zero;
+    x = minus_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));
--- tests/test-roundl.c.orig    2008-10-08 01:48:16.000000000 +0200
+++ tests/test-roundl.c 2008-10-08 01:40:44.000000000 +0200
@@ -22,6 +22,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -40,9 +41,9 @@
     }                                                                       \
   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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -53,7 +54,7 @@
 
   /* Zero.  */
   ASSERT (roundl (0.0L) == 0.0L);
-  ASSERT (roundl (-zero) == 0.0L);
+  ASSERT (roundl (minus_zero) == 0.0L);
   /* Positive numbers.  */
   ASSERT (roundl (0.3L) == 0.0L);
   ASSERT (roundl (0.5L) == 1.0L);
--- tests/test-signbit.c.orig   2008-10-08 01:48:16.000000000 +0200
+++ tests/test-signbit.c        2008-10-08 01:40:47.000000000 +0200
@@ -20,6 +20,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -40,6 +41,16 @@
 double zerod = 0.0;
 long double zerol = 0.0L;
 
+/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0f.
+   So we use -zerof instead.  */
+
+/* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
+   So we use -zerod instead.  */
+
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
+
 static void
 test_signbitf ()
 {
@@ -140,10 +151,10 @@
   ASSERT (signbit (-2.718e-30L));
   /* Zeros.  */
   ASSERT (!signbit (0.0L));
-  if (1.0L / -zerol < 0)
-    ASSERT (signbit (-zerol));
+  if (1.0L / minus_zerol < 0)
+    ASSERT (signbit (minus_zerol));
   else
-    ASSERT (!signbit (-zerol));
+    ASSERT (!signbit (minus_zerol));
   /* Infinite values.  */
   ASSERT (!signbit (1.0L / 0.0L));
   ASSERT (signbit (-1.0L / 0.0L));
--- tests/test-snprintf-posix.h.orig    2008-10-08 01:48:16.000000000 +0200
+++ tests/test-snprintf-posix.h 2008-10-08 01:40:49.000000000 +0200
@@ -28,12 +28,12 @@
 }
 
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
+   So we use -zerod 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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
@@ -444,7 +444,7 @@
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%La %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%La %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1146,7 +1146,7 @@
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%Lf %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%Lf %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1513,7 +1513,7 @@
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%LF %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%LF %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -2015,7 +2015,7 @@
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%Le %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%Le %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
              || strcmp (result, "-0.000000e+000 33") == 0);
@@ -2668,7 +2668,7 @@
   { /* Negative zero.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%Lg %d", -zerol, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%Lg %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);
     ASSERT (retval == strlen (result));
--- tests/test-sprintf-posix.h.orig     2008-10-08 01:48:16.000000000 +0200
+++ tests/test-sprintf-posix.h  2008-10-08 01:40:52.000000000 +0200
@@ -28,12 +28,12 @@
 }
 
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
+   So we use -zerod 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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
@@ -430,7 +430,7 @@
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%La %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%La %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1132,7 +1132,7 @@
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%Lf %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%Lf %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -1499,7 +1499,7 @@
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%LF %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%LF %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
     ASSERT (retval == strlen (result));
@@ -2001,7 +2001,7 @@
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%Le %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%Le %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
              || strcmp (result, "-0.000000e+000 33") == 0);
@@ -2654,7 +2654,7 @@
   { /* Negative zero.  */
     char result[1000];
     int retval =
-      my_sprintf (result, "%Lg %d", -zerol, 33, 44, 55);
+      my_sprintf (result, "%Lg %d", minus_zerol, 33, 44, 55);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);
     ASSERT (retval == strlen (result));
--- tests/test-truncl.c.orig    2008-10-08 01:48:16.000000000 +0200
+++ tests/test-truncl.c 2008-10-08 01:40:55.000000000 +0200
@@ -20,6 +20,7 @@
 
 #include <math.h>
 
+#include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -38,9 +39,9 @@
     }                                                                       \
   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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zero instead.  */
+long double minus_zero = -LDBL_MIN * LDBL_MIN;
 
 int
 main ()
@@ -51,7 +52,7 @@
 
   /* Zero.  */
   ASSERT (truncl (0.0L) == 0.0L);
-  ASSERT (truncl (-zero) == 0.0L);
+  ASSERT (truncl (minus_zero) == 0.0L);
   /* Positive numbers.  */
   ASSERT (truncl (0.3L) == 0.0L);
   ASSERT (truncl (0.7L) == 0.0L);
--- tests/test-vasnprintf-posix.c.orig  2008-10-08 01:48:16.000000000 +0200
+++ tests/test-vasnprintf-posix.c       2008-10-08 01:40:58.000000000 +0200
@@ -53,12 +53,12 @@
 }
 
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
+   So we use -zerod 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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
@@ -539,7 +539,7 @@
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%La %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%La %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
@@ -1351,7 +1351,7 @@
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%Lf %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%Lf %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -1798,7 +1798,7 @@
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%LF %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%LF %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -2372,7 +2372,7 @@
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%Le %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%Le %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
@@ -3127,7 +3127,7 @@
   { /* Negative zero.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%Lg %d", -zerol, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%Lg %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);
--- tests/test-vasprintf-posix.c.orig   2008-10-08 01:48:16.000000000 +0200
+++ tests/test-vasprintf-posix.c        2008-10-08 01:41:00.000000000 +0200
@@ -53,12 +53,12 @@
 }
 
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
-   So we use -zero instead.  */
+   So we use -zerod 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;
+/* On HP-UX 10.20, negating 0.0L does not yield -0.0L.
+   So we use minus_zerol instead.  */
+long double minus_zerol = -LDBL_MIN * LDBL_MIN;
 
 /* Representation of an 80-bit 'long double' as an initializer for a sequence
    of 'unsigned int' words.  */
@@ -520,7 +520,7 @@
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%La %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%La %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0x0p+0 33") == 0);
@@ -1332,7 +1332,7 @@
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%Lf %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%Lf %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -1779,7 +1779,7 @@
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%LF %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%LF %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000 33") == 0);
@@ -2353,7 +2353,7 @@
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%Le %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%Le %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0.000000e+00 33") == 0
@@ -3108,7 +3108,7 @@
   { /* Negative zero.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%Lg %d", -zerol, 33, 44, 55);
+      my_asprintf (&result, "%Lg %d", minus_zerol, 33, 44, 55);
     ASSERT (result != NULL);
     if (have_minus_zero ())
       ASSERT (strcmp (result, "-0 33") == 0);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]