[llvm-bugs] [Bug 50114] New: MemorySanitizer: use-of-uninitialized-value in std::string s = "x"; std::strlen(s.c_str());
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Apr 24 08:49:06 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50114
Bug ID: 50114
Summary: MemorySanitizer: use-of-uninitialized-value in
std::string s = "x"; std::strlen(s.c_str());
Product: libc++
Version: 10.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
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";
(void)std::strlen(s.c_str());
}
clang++-11 -fsanitize=memory -stdlib=libc++ -g z.cpp -o z && ./z
==63085==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x49a3ab in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::__get_pointer() const
/usr/lib/llvm-11/bin/../include/c++/v1/string:1517:17
#1 0x49a2b8 in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::data() const
/usr/lib/llvm-11/bin/../include/c++/v1/string:1245:75
#2 0x499f10 in std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::c_str() const
/usr/lib/llvm-11/bin/../include/c++/v1/string:1243:55
#3 0x499d34 in main /home/user/z.cpp:6:25
#4 0x7f8a3bdb6cb1 in __libc_start_main csu/../csu/libc-start.c:314:16
#5 0x41d26d in _start (/home/user/z+0x41d26d)
SUMMARY: MemorySanitizer: use-of-uninitialized-value
/usr/lib/llvm-11/bin/../include/c++/v1/string:1517:17 in
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::__get_pointer() const
Exiting
Clang/libc++ 10+ are affected
https://godbolt.org/z/h8Y5K1M9K
--
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/703f4c32/attachment.html>
More information about the llvm-bugs
mailing list