On 3/28/2011 6:26 PM, Santosh Navale wrote:
Hi,
The following is the message I get when I run valgrind on my C code.
==16455== Use of uninitialised value of size 8
==16455== at 0x4E6A76B: _itoa_word (_itoa.c:195)
==16455== by 0x4E6B9B8: vfprintf (vfprintf.c:1613)
==16455== by 0x4E75869: printf (printf.c:35)
==16455== by 0x400830: main (matrix1.c:42)
==16455== Uninitialised value was created by a heap allocation
==16455== at 0x4C244E8: malloc (vg_replace_malloc.c:236)
==16455== by 0x400752: main (matrix1.c:28)
From my understanding something on line 28 in the file matrix1.c is
causing an error. When I look at the source code,
matrix = (int **) malloc (size * sizeof(int *));
for (row = 0; row < size; row++) {
matrix[row] = (int *) malloc (size * sizeof(int));
<------------------- Line 28
}
I do not see how this can be a problem. Am I missing something very
fundamental?
Any suggestion is appreciated.
Line 28 is where the data is allocated; line 42 is where Valgrind says
it is referenced before being initialized. From the call stack, it
appears that you are trying to print some matrix[i][j] using a printf()
call on line 42.
--
David Chapman dcchap...@acm.org
Chapman Consulting -- San Jose, CA
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users