Emmanuel Dreyfus
2014-09-15 04:35:58 UTC
Hello
Consider the program below and its output. Am I using strtoll() wrongly,
or is this a bug? (this is netbsd-7 branch)
$ cat /tmp/x.c
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
int
main(void)
{
const char *ptr = "999999999999999";
char *endp;
long long int res;
errno = 0;
res = strtoll(ptr, &endp, 0);
printf("errno = %d\n", errno);
printf("*endp = 0x%02x\n", *endp);
printf("str %s\n", ptr);
printf("num %lld\n", res);
return 0;
}
$ cc -o /tmp/x /tmp/x.c
$ /tmp/x
errno = 0
*endp = 0x00
str 999999999999999
num -1530494977
Consider the program below and its output. Am I using strtoll() wrongly,
or is this a bug? (this is netbsd-7 branch)
$ cat /tmp/x.c
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
int
main(void)
{
const char *ptr = "999999999999999";
char *endp;
long long int res;
errno = 0;
res = strtoll(ptr, &endp, 0);
printf("errno = %d\n", errno);
printf("*endp = 0x%02x\n", *endp);
printf("str %s\n", ptr);
printf("num %lld\n", res);
return 0;
}
$ cc -o /tmp/x /tmp/x.c
$ /tmp/x
errno = 0
*endp = 0x00
str 999999999999999
num -1530494977
--
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
***@netbsd.org
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
***@netbsd.org