条件跳转或移动取决于未初始化的值4

时间:2015-03-25 10:55:21

标签: valgrind

valgrind显示了这样的错误..

   7471== 7 errors in context 4 of 6:
    ==17471== Conditional jump or move depends on uninitialised value(s)
    ==17471==    at 0x36EA6718D0: _IO_file_xsputn@@GLIBC_2.2.5 (in /lib64/libc-2.12.so)
    ==17471==    by 0x36EA64818F: vfprintf (in /lib64/libc-2.12.so)
    ==17471==    by 0x36EA64F189: printf (in /lib64/libc-2.12.so)
    ==17471==    by 0x4008F3: main (main.c:84)
    ==17471==  Uninitialised value was created by a stack allocation
    ==17471==    at 0x4004E8: ??? (in /user/gur39229/extension/assign1/bin/exe)
    ==17471==
    ==17471==
    ==17471== 8 errors in context 5 of 6:
    ==17471== Conditional jump or move depends on uninitialised value(s)
    ==17471==    at 0x36EA647E2C: vfprintf (in /lib64/libc-2.12.so)
    ==17471==    by 0x36EA64F189: printf (in /lib64/libc-2.12.so)
    ==17471==    by 0x4008F3: main (main.c:84)
    ==17471==  Uninitialised value was created by a stack allocation
    ==17471==    at 0x4004E8: ??? (in /user/gur39229/extension/assign1/bin/exe)
    ==17471==
    ==17471==
    ==17471== 8 errors in context 6 of 6:
    ==17471== Conditional jump or move depends on uninitialised value(s)
    ==17471==    at 0x4A07FB7: strcpy (mc_replace_strmem.c:442)
    ==17471==    by 0x4008CC: main (main.c:83)
    ==17471==  Uninitialised value was created by a stack allocation
    ==17471==    at 0x4004E8: ??? (in /user/gur39229/extension/assign1/bin/exe)

我的代码:请在启动后检查代码的所有初始化和变量的使用。在第一行。 83它说没有初始化......是吗?我不明白..请帮助。

    /*Declaration*/
 42         int i = 0;
 43         int a[4]={0};
 44         char cstr[80];
 45         memset(cstr,0,80);
 46         int largest = 0;


     if(largest == 3)
 82                 {
 83                         strcpy(cstr,str_concat(v[1],v[2]));
 84                         printf("\t%s%s\n\n",cstr,v[3]);
 85
 86                 }

虽然我已初始化每个变量仍显示valgrind错误该怎么办?

0 个答案:

没有答案