[llvm-bugs] [Bug 50112] New: MemorySanitizer: use-of-uninitialized-value in std::string s = "x"; std::replace(s.begin(), s.end(), 'a', 'b'); on -O0
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Apr 24 08:40:25 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50112
Bug ID: 50112
Summary: MemorySanitizer: use-of-uninitialized-value in
std::string s = "x"; std::replace(s.begin(), s.end(),
'a', 'b'); on -O0
Product: libc++
Version: 10.0
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: nok.raven at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
#include <string>
int main()
{
std::string s = "x";
std::replace(s.begin(), s.end(), 'a', 'b');
}
clang++-11 -fsanitize=memory -stdlib=libc++ -g z.cpp -o z && ./z
==62635==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x49a95b in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::__get_pointer()
/usr/lib/llvm-11/bin/../include/c++/v1/string:1514:17
#1 0x49a461 in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::begin()
/usr/lib/llvm-11/bin/../include/c++/v1/string:909:26
#2 0x499d79 in main /home/user/z.cpp:6:20
#3 0x7fcd8bd35cb1 in __libc_start_main csu/../csu/libc-start.c:314:16
#4 0x41d26d in _start (/home/user/z+0x41d26d)
SUMMARY: MemorySanitizer: use-of-uninitialized-value
/usr/lib/llvm-11/bin/../include/c++/v1/string:1514:17 in
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::__get_pointer()
Exiting
Clang/libc++ 10+ are affected
https://godbolt.org/z/6E9aeWjjP
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210424/497c0228/attachment.html>
More information about the llvm-bugs
mailing list