我在 x86-64 上使用 manjaro linux。clang 版本 10.0.1 中的 Memory-sanitizer 报告了一个 use of uninitialized value in 错误std::map
,这让我很惊讶。我做错什么了吗?
$ cat test.cpp
#include <map>
int main() {
std::map<int, int> test;
test.insert({1,2});
}
$ clang++ -fsanitize=memory test.cpp && ./a.out
==51936==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x562889eaad9a (/tmp/build/a.out+0x9fd9a)
#1 0x562889eaae28 (/tmp/build/a.out+0x9fe28)
#2 0x562889eaaba1 (/tmp/build/a.out+0x9fba1)
#3 0x562889eaa51e (/tmp/build/a.out+0x9f51e)
#4 0x562889eaa087 (/tmp/build/a.out+0x9f087)
#5 0x7f418e02b151 (/usr/lib/libc.so.6+0x28151)
#6 0x562889e2b1dd (/tmp/build/a.out+0x201dd)
SUMMARY: MemorySanitizer: use-of-uninitialized-value (/tmp/build/a.out+0x9fd9a)
Exiting