https://bugs.kde.org/show_bug.cgi?id=492549
--- Comment #5 from martin.lu...@ohb.de --- It seems that the behaviour of __builtin_memchr depends on where the source string is stored. The following two programs have different output with massif, but otherwise the same output: Always says 0 (= not found): #include <string> #include <iostream> int main() { std::cout << (void*) __builtin_memchr("haystack", 'x', 1) << std::endl; } Says 0 normally, but 0x1fff000120 (a heap address?) with massif: #include <string> #include <iostream> int main() { std::string s = "haystack"; std::cout << (void*) __builtin_memchr(s.c_str(), 'x', 1) << std::endl; } But it looks like the same happens on the stack, massif returns 0x1fff000147 here again, but normal run returns 0: #include <string> #include <iostream> int main() { char sample[] = { 'h', 'a', 'y', 's', 't', 'a', 'c', 'k', 0 }; std::cout << (void*) __builtin_memchr(sample, 'x', 1) << std::endl; } However, just making sample a const char works: #include <string> #include <iostream> int main() { const char sample[] = { 'h', 'a', 'y', 's', 't', 'a', 'c', 'k', 0 }; std::cout << (void*) __builtin_memchr(sample, 'x', 1) << std::endl; } ~ $ ./a.out 0 ~ $ valgrind -q --tool=massif ./a.out 0 -- You are receiving this mail because: You are watching all bug changes.