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

Bug#210981: libc6: printf crashes on a certain long double



On Mon, Sep 15, 2003 at 00:00:27 -0400, Daniel Jacobowitz wrote:
> Package: libc6
> Version: 2.3.2-7
> Severity: normal
> 
> Try it:
> 
> int data[] = {0x00000000, 0x00000000, 0x00000cd0};
> struct ieee {
>         unsigned int mantissa1:32;
>         unsigned int mantissa0:30;
>         unsigned int quiet_nan:1;
>         unsigned int one:1;
>         unsigned int exponent:15;
>         unsigned int negative:1;
>         unsigned int empty:16;
> } *pieee = data;
> long double *doub = (long double *) data;
> int main()
> {
>   char *ret = 0;
>   printf ("%.35Lg\n", *doub);
>   vasprintf (&ret, "%.35Lg", doub);
>   printf ("%s\n", ret);
> }
> 
> That number is:
> 
> $2 = {mantissa1 = 0, mantissa0 = 0, quiet_nan = 0, one = 0, exponent = 3280, negative = 0, empty = 0}
> 
> which ought to be a perfectly valid floating point number, as far as I can
> tell?
[...]

Are you sure? AFAIK, 3280 is not a valid exponent for 0 and the
first bit of the mantissa must be a 1 (which is represented in
extended precision) for non-zero normal numbers.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated HTML - Acorn Risc PC, Yellow Pig 17, Championnat International des
Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA



Reply to: