关于valgrind的 “Conditional jump or move depends on uninitialised value(s)”:

valgrind在报这个错误的时候程序未必有bug,如下例:

//test.cpp
#include <iostream>
using namespace std;
bool ptr(char *testptr)
{
        
int i=0;
        
if(i == 0){
                memcpy(testptr,
"Hello",5);
                
return true;
        }
        
return false;
}

int main(int argc, const char *argv[])
{
        
char *= new char [10];
        
if(ptr(p)){
                printf(
"%s\n",p);
        }

        delete [] p;

        
return 0;
}

相关文章:

  • 2022-02-28
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2021-06-23
  • 2022-12-23
  • 2021-12-28
相关资源
相似解决方案