int main(int argc, char* argv[])
{
string s1 = "String";
char *s2 = strdup(s1.c_str());
free(s2);
return 0;
}
Valgrind在上面发布的代码中报告了以下内容:
==29608== Conditional jump or move depends on uninitialised value(s)
==29608== at 0x41F9049: ??? (in /usr/local/lib/libc.so.6)
==29608== by 0x41F8C25: strdup (in /usr/local/lib/libc.so.6)
==29608== by 0x804D704: main
Valgrind在抱怨什么?我可以安全地忽略这个错误吗?