The function strtod in GLIBC, (implemented in stdlib/strtod_l.c), has a bug when checking for "inf" or "nan" in strtod_l.c. The issue causes Valgrind to report an invalid memory access. It can be reproduced easily by simply trying to use strtod on a string that starts with the letter "i" or "n": char* s = malloc(12); memset(s, 0, 12); strcpy(s, "ichabod"); double v = std::strtod(s, NULL); This causes Valgrind to report: ==20062== Invalid read of size 8 ==20062== at 0x565A147: __GI___strncasecmp_l (strcmp.S:215) ==20062== by 0x5610F5E: ____strtod_l_internal (strtod_l.c:577) ==20062== by 0x404B43: main (test4.cc:310) ==20062== Address 0x5971048 is 8 bytes inside a block of size 12 alloc'd ==20062== at 0x4C28F9F: malloc (vg_replace_malloc.c:236) ==20062== by 0x404B07: main (test4.cc:307) The bug seems to have something to do with the use of STRNCASECMP macro when checking for "inf" and "nan".
This is a false positive due to read-ahead and reading from a 16-byte aligned address cannot cross a page boundary. valgrind needs to white-list that access.