[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1
From: |
Bruno Haible |
Subject: |
Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1 |
Date: |
Tue, 20 Nov 2007 19:18:21 +0100 |
User-agent: |
KMail/1.5.4 |
Jim Meyering wrote:
> It seems to have exposed a problem in gnulib's vasnprintf.c:
>
> freebsd6$ gdb --args ./seq 0.8 0.1 0.9
> GNU gdb 6.6
> (gdb) r
> Starting program: /tmp/coreutils-6.9.89.27-a9805-dirty/src/seq 0.8 0.1 0.9
> 0.8
> Program received signal SIGABRT, Aborted.
> 0x28136363 in kill () from /lib/libc.so.6
> (gdb) up
> #1 0x28136300 in raise () from /lib/libc.so.6
> (gdb)
> #2 0x28135014 in abort () from /lib/libc.so.6
> (gdb)
> #3 0x0804d8f1 in decode_long_double
> (x=0.80000000000000000001084202172485504,
> ep=0xbfbfe1e0, mp=0xbfbfe1d8) at vasnprintf.c:877
> 877 abort ();
> (gdb) l
> 872 if (!(y >= 0.0L && y < 1.0L))
> 873 abort ();
> 874 m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
> 875 }
> 876 if (!(y == 0.0L))
> 877 abort ();
> 878 /* Normalise. */
> 879 while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0)
> 880 m.nlimbs--;
> 881 *mp = m;
> (gdb) p y
> $1 = 0.60009765625
> (gdb) p ep
> $2 = (int *) 0xbfbfe1e0
> (gdb) p *ep
> $3 = -858993460
> (gdb) up
> #4 0x0804e3ca in scale10_round_decimal_long_double (
> x=0.80000000000000000001084202172485504, n=1) at vasnprintf.c:1205
> 1205 void *memory = decode_long_double (x, &e, &m);
> (gdb) p x
> $4 = 0.80000000000000000001084202172485504
> (gdb) dow
> #3 0x0804d8f1 in decode_long_double
> (x=0.80000000000000000001084202172485504,
> ep=0xbfbfe1e0, mp=0xbfbfe1d8) at vasnprintf.c:877
> 877 abort ();
> (gdb) l
> 872 if (!(y >= 0.0L && y < 1.0L))
> 873 abort ();
> 874 m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
> 875 }
> 876 if (!(y == 0.0L))
> 877 abort ();
It looks like the calculations with 'long double's are computed with ca.
16 bits more precision than what LDBL_MANT_BIT says. I can not reproduce the
problem with a small test program on FreeBSD/x86 6.1:
============================= foo.c =============================
#include <stdio.h>
long double a = 4.0L;
long double b = 5.0L;
int main ()
{
long double x = a / b;
printf ("%.1Le\n", x);
printf ("%.1Lf\n", x);
printf ("%.1Lg\n", x);
return 0;
}
==================================================================
What's the CPU in use?
"info registers" ?
Value of LDBL_MANT_BIT?
sizeof (long double) = ?
Can you show the output of
(gdb) set height 1000
(gdb) disassemble decode_long_double
?
Bruno
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Jim Meyering, 2007/11/20
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Paul Eggert, 2007/11/20
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1,
Bruno Haible <=
- Message not available
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Bruno Haible, 2007/11/20
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Paul Eggert, 2007/11/20
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Bruno Haible, 2007/11/20
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Jim Meyering, 2007/11/21
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Bruno Haible, 2007/11/21
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Jim Meyering, 2007/11/21
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Paul Eggert, 2007/11/21
- Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1, Paul Eggert, 2007/11/21