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

Bug#465769: libc gets some strtod() cases wrong



pmaydell@chiark.greenend.org.uk a écrit :
> Package: libc6
> Version: 2.3.6.ds1-13etch4
> 
> GNU libc seems to get some of the odder reaches of the C99 strtod()
> spec wrong. Observe:
> 
> mnementh$ cat strtod-test.c
> #include <stdlib.h>
> #include <stdio.h>
> int main(int argc, char **argv) {
>   double d;
>   char *endp;
>   char *s = argv[1];
>   if (argc != 2)
>   {
>     printf("Usage: %s string\n", argv[0]);
>     return 1;
>   }
>   d = strtod(s, &endp);
>   printf("Got value %g, string tail %s\n", d, endp);
>   return 0;
> }
> mnementh$ gcc -g -Wall -o strtod-test strtod-test.c
> mnementh$ ./strtod-test 0xYOW
> Got value 0, string tail YOW
> 
> [Should be tail xYOW -- C99 7.20.1.3 para 3 says the hex digits after
> the "0x" must be a non-empty string. So the longest initial subsequence
> matching the expected form is just "0", not "0x".]

This bug is fixed in glibc 2.7.

> mnementh$ ./strtod-test 'Nan(anana)ana'
> Got value nan, string tail )ana
> 
> [Should be tail ana -- the trailing ')' is also part of the expected
> form in the NAN(n-char-seq-opt) form. 7.20.1.3 p3 again.]

This one is still present.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net



Reply to: