bug-gnulib
[Top][All Lists]
Advanced

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

Re: frexpl bugs remain on OS X 10.5 intel


From: Gary V. Vaughan
Subject: Re: frexpl bugs remain on OS X 10.5 intel
Date: Fri, 25 Jan 2008 13:23:36 +0800

Hi Bruno,

On 25 Jan 2008, at 10:50, Bruno Haible wrote:
Gary V. Vaughan wrote:
Can you run the test program mentioned in [2]?

Sure:

$ gcc -o testfrexpl testfrexpl.c
$ ./testfrexpl
-16384 0.5
...
checking whether frexpl works... yes

Sorry, this makes no sense to me. The testfrexpl.c test is nearly literally
contained in the "whether frexpl works" check.

:-( Well, let's see if we can figure out what's going wrong...

Can you verify that the configure file, when doing the "whether frexpl works"
check, runs a program that includes the
 /* Test on denormalized numbers.  */
section?

It doesn't. That section does appear in configure, but only for the frexp test:

$as_echo_n "checking whether frexp works... " >&6; }
if test "${gl_cv_func_frexp_works+set}" = set; then
  $as_echo_n "(cached) " >&6
else

      if test "$cross_compiling" = yes; then
  case "$host_os" in
netbsd* | irix* | mingw*) gl_cv_func_frexp_works="guessing no";; *) gl_cv_func_frexp_works="guessing yes";;
       esac

else
  cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h.  */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h.  */

#include <float.h>
#include <math.h>
int main()
{
  int i;
  volatile double x;
  /* Test on denormalized numbers.  */
  for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5)
    ;
  if (x > 0.0)
    {
      int exp;
      double y = frexp (x, &exp);
/* On machines with IEEE754 arithmetic: x = 1.11254e-308, exp = -1022.
         On NetBSD: y = 0.75. Correct: y = 0.5.  */
      if (y != 0.5)
        return 1;
    }
  /* Test on infinite numbers.  */
  x = 1.0 / 0.0;
  {
    int exp;
    double y = frexp (x, &exp);
    if (y != x)
      return 1;
  }
  return 0;
}
_ACEOF


By comparison the expanded frexpl test in configure is:

$as_echo_n "checking whether frexpl works... " >&6; }
if test "${gl_cv_func_frexpl_works+set}" = set; then
  $as_echo_n "(cached) " >&6
else

      if test "$cross_compiling" = yes; then
  case "$host_os" in
         aix* | beos* | darwin* | irix* | mingw* | pw*)
            gl_cv_func_frexpl_works="guessing no";;
         *) gl_cv_func_frexpl_works="guessing yes";;
       esac

else
  cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h.  */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h.  */

#include <math.h>
extern long double frexpl (long double, int *);
int main()
{
  volatile long double x;
  /* Test on finite numbers that fails on AIX 5.1.  */
  x = 16.0L;
  {
    int exp = -9999;
    frexpl (x, &exp);
    if (exp != 5)
      return 1;
  }
/* Test on finite numbers that fails on MacOS X 10.4, because its frexpl function returns an invalid (incorrectly normalized) value: it returns
               y = { 0x3fe028f5, 0xc28f5c28, 0x3c9eb851, 0xeb851eb8 }
     but the correct result is
0.505L = { 0x3fe028f5, 0xc28f5c29, 0xbc547ae1, 0x47ae1480 } */
  x = 1.01L;
  {
    int exp = -9999;
    long double y = frexpl (x, &exp);
    if (!(exp == 1 && y == 0.505L))
      return 1;
  }
/* Test on large finite numbers. This fails on BeOS at i = 16322, while
     LDBL_MAX_EXP = 16384.
In the loop end test, we test x against Infinity, rather than comparing i with LDBL_MAX_EXP, because BeOS <float.h> has a wrong LDBL_MAX_EXP. */
  {
    int i;
    for (i = 1, x = 1.0L; x != x + x; i++, x *= 2.0L)
      {
        int exp = -9999;
        frexpl (x, &exp);
        if (exp != i)
          return 1;
      }
  }
  /* Test on infinite numbers.  */
  x = 1.0L / 0.0L;
  {
    int exp;
    long double y = frexpl (x, &exp);
    if (y != x)
      return 1;
  }
  return 0;
}
_ACEOF


If yes, then it's time to compare the gcc option with which one and the
other programs were compiled.
 $ grep CC config.status
 $ grep CFLAGS config.status
 $ grep CPPFLAGS config.status

I changed the regexps slightly to cut down on noise:

$ grep '^CC=' config.status
CC='gcc -std=gnu99'
CC=$lt_compiler
$ grep ^CFLAGS= config.status
CFLAGS='-O2 -pipe'
$ grep CPPFLAGS config.status
S["CPPFLAGS"]=""

I believe that is 64 bit mode, unless I'm just falling for the hype...

Belief is not something we can build on here. Can you test it, please?
 $ touch empty.c
 $ gcc -E -dM empty.c | grep 86

My bad, I didn't know how to check.  This confirms what Peter said about
my being wrong, and Leopard using 32 bit compilation by default:

$ gcc -E -dM empty.c | grep 86
#define __DBL_MAX__ 1.7976931348623157e+308
#define __i386 1
#define i386 1
#define __i386__ 1

Bruno

Cheers,
        Gary
--
  ())_.              Email me: address@hidden
  ( '/           Read my blog: http://blog.azazil.net
  / )=         ...and my book: http://sources.redhat.com/autobook
`(_~)_




Attachment: PGP.sig
Description: This is a digitally signed message part


reply via email to

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