bug-glibc
[Top][All Lists]
Advanced

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

Re: Bug inside the function strtold()


From: Ivano Primi
Subject: Re: Bug inside the function strtold()
Date: Tue, 20 Jul 2004 14:15:03 +0200 (MEST)

I lost the files originally sent during an OS upgrade (now i am
working with Slackware GNU/Linux version 10.0). For me does
not make any difference if the bug will be reported by you rather than by
me, but if you are busy i will do it for you by using the source code
below. Best regards

                                   Ivano Primi

On Tue, 20 Jul 2004, Petter Reinholdtsen wrote:

> 
> [Ivano Primi, 2003-12-03]
> > I have just found a bug in the package glibc-2.3.2. This bug
> > concerns the function strtold(), as showed below.
> 
> I rewrote your test program to be more self contained, and tested it
> on Debian/unstable.  It fails here too.
> 
> Perhaps you want to report it to the glibc bugzilla available from
> <URL:http://sources.redhat.com/bugzilla/>?
> 
> /*
>  * Demonstrate bug in strtold() in glibc.  The last two number strings
>  * converts to 0, not 42 as it should.
>  * Based on code from Ivano Primi and modified by Petter Reinholdtsen.
>  */
> #include <stdio.h>
> #include <stdlib.h>
> #include <errno.h>
> 
> extern int errno;
> extern long double strtold(const char *nptr, char **endptr);
> 
> int main (void)
> {
>   char *numbers[] = {
>     "42.0000000000000000001",
>     "42.00000000000000000001",
>     "42.0000000000000000000001",
>     };
>   char* endptr;
>   long double x;
>   int i;
> 
>   errno = 0;
>   for (i = 0; i < 3; i++) {
>     x = strtold (numbers[i], &endptr);
>     if ( endptr == numbers[i] && x == 0 )
>       {
>         fprintf (stderr, " *** Unagreable input\n");
>         return 1;
>       }
>     else if ( errno != 0 )
>       {
>         if ( x == 0 )
>           fprintf (stderr, " *** Underflow\n");
>         else
>           fprintf (stderr, " *** Overflow\n");
>         return 2;
>       }
>     else
>       {
>         printf ("String '%s' converts to long double %.20Lf\n", numbers[i], 
> x);
>       }
>   }
>   return 0;
> }
> 





reply via email to

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