[Top][All Lists]
[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: |
Sat, 13 Sep 2008 10:52:30 +0200 |
User-agent: |
KMail/1.5.4 |
Eric Blake wrote:
> It looks like you failed to check .m4 tests. I'm applying the patch
> below.
Yes, I missed to change the .m4 tests. Thank you for the fix.
> Meanwhile, I have a question about tests/test-signbit.c - your
> patch changed most occurrences of -0.0L to -zerol, to work around one HP
> bug, but there is another comment that states:
>
> /* We cannot use the expression '-zerol' here, because on HP-UX/hppa it
> evaluates to 0.0L, not -0.0L. */
> long double minus_zerol = -0.0L;
>
> and still uses minus_zerol throughout the file. So which is it, or are we
> really stuck with no portable way to represent negative zero across the
> spectrum of HP compilers/architectures?
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>
It requires more creativity to write a negative 'long double' zero that
all compilers will understand. The updated test program
============================ fool.c ==================================
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
long double x = 1.0L;
long double y = -0.0L;
long double z = 0.0L;
int different_from_plus_zero (long double arg)
{
return memcmp (&arg, &z, sizeof (z)) != 0;
}
int main()
{
printf ("%Lf\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
#define x 1.0L
#define y -0.0L
printf ("%Lf\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
#undef y
#define y -z
printf ("%Lf\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
#undef y
#define y (-0.1L * LDBL_MIN)
printf ("%Lf\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
#undef y
#define y (-0.1L / LDBL_MAX)
printf ("%Lf\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
return 0;
}
====================================================================
yields the following output on HP-UX 11:
-inf
1
1
1
-inf
1
1
1
inf
0
0
0
-inf
1
1
1
-inf
1
1
1
Jonathan, could you please run this on your HP-UX 10.20 machine? What is
the result? Also, for completeness, what result do you get for
============================ food.c ==================================
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
double x = 1.0;
double y = -0.0;
double z = 0.0;
int different_from_plus_zero (double arg)
{
return memcmp (&arg, &z, sizeof (z)) != 0;
}
int main()
{
printf ("%f\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
#define x 1.0
#define y -0.0
printf ("%f\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
#undef y
#define y -z
printf ("%f\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
#undef y
#define y (-0.1 * DBL_MIN)
printf ("%f\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
#undef y
#define y (-0.1 / DBL_MAX)
printf ("%f\n", x / y);
printf ("%d\n", x / y < 0);
printf ("%d\n", signbit (x/y) != 0);
printf ("%d\n", different_from_plus_zero (y));
return 0;
}
====================================================================
?
Bruno