问题描述
我正在尝试在RaspBerry Pi上使用Valgrind。我正在分析以下程序:
#include <string>
#include <cstring>
int main() {
std::string blaat = "blaat";
const char * buf = blaat.c_str();
size_t l = 0;
l = strlen(buf);
printf("string size %u\n",l);
}
编译:
g++ -g -Wall -O0 test.cpp
分析(valgrind-3.16.1):
valgrind --leak-check=yes ./a.out
结果:
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4866210: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x48662DC: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so)
==29572==
==29572== Use of uninitialised value of size 4
==29572== at 0x4AABF6C: _itoa_word (_itoa.c:179)
==29572== by 0x4AB0727: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AABF74: _itoa_word (_itoa.c:179)
==29572== by 0x4AB0727: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AAF8FC: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AAF99C: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AAFA00: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AAFA7C: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
一旦我使用“ strlen”,Valgrind就会向我发出有关未初始化值的警告。为什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)