Current-Users archive

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

strtod(3) sets errno upon success ?


I just encountered a small problem with strtod(3) that alter errno
upon success, on my up-to-date -current amd64 and alpha machines. The
following sample code exhibit the problem :

njoly@petaure [tmp/strtod]> cat strtod.c
#include <assert.h>
#include <errno.h>
#include <stdlib.h>

int main() {
  const char *str;
  double d;

  str = "1.0"; errno = 0;
  d = strtod(str, NULL);
  assert(d == 1.0);
  assert(errno == 0);

  return 0; }
njoly@petaure [tmp/strtod]> cc -g -o strtod strtod.c; echo $?
njoly@petaure [tmp/strtod]> ./strtod
assertion "errno == 0"failed: file "strtod.c",line 12,function "main"
zsh: abort (core dumped)  ./strtod

njoly@petaure [tmp/strtod]> gdb strtod strtod.core
GNU gdb 6.5
Core was generated by `strtod'.
Program terminated with signal 6,Aborted.
#0  0x00007f7ff78e984a in _lwp_kill () from /usr/lib/
(gdb) bt
#0  0x00007f7ff78e984a in _lwp_kill () from /usr/lib/
#1  0x00007f7ff78e91be in abort ()
    at /local/src/NetBSD/src/lib/libc/stdlib/abort.c:74
#2  0x00007f7ff7860c74 in __assert13 (file=<value optimized out>,
    line=<value optimized out>,function=<value optimized out>,
    failedexpr=<value optimized out>)
    at /local/src/NetBSD/src/lib/libc/gen/assert.c:61
#3  0x0000000000400a0e in main () at strtod.c:12
(gdb) frame 3
#3  0x0000000000400a0e in main () at strtod.c:12
12        assert(errno == 0);
(gdb) p errno
$1 = 2

Anyone else ?


Nicolas Joly

Projects and Developments in Bioinformatics
Institut Pasteur, Paris.

Home | Main Index | Thread Index | Old Index