Bug#465769: libc gets some strtod() cases wrong
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".]
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.]
-- PMM
Reply to: