https://bugs.kde.org/show_bug.cgi?id=492549

--- Comment #2 from martin.lu...@ohb.de ---
Looking at basic_string.tcc from
https://github.com/gcc-mirror/gcc/blob/releases/gcc-11/libstdc%2B%2B-v3/include/bits/basic_string.tcc
I found that:
- find(char)  uses __gnu_cxx::char_traits<char>::find
- find(const char*) uses  __gnu_cxx::char_traits<char>::find for the first
character, followed by __gnu_cxx::char_traits<char>::compare to check all
characters to match.

In the specialization for char_traits<char>, these are implemented
(https://github.com/gcc-mirror/gcc/blob/releases/gcc-11/libstdc%2B%2B-v3/include/bits/char_traits.h#L413)
as:

find() with __builtin_memchr, compare() with __builtin_memcmp.


I checked with clang and it gives the same result:

~ $ clang++ test.cpp
~ $ ./a.out
18446744073709551615
18446744073709551615
~ $ valgrind -q ./a.out
18446744073709551615
18446744073709551615
~ $ valgrind -q --tool=massif ./a.out
0
18446744073709551615
~ $ clang --version
clang version 15.0.7 (Red Hat 15.0.7-2.0.1.el9)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
~ $

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to