|
From: Edward M. <Edw...@ce...> - 2004-04-30 17:55:28
|
On Friday 30 April 2004 19:26, David Hawkins wrote: > > His response was that it looked like there were two char[3] > > arrays, but the last element of the array was unitialised, > > causing the valgrind error. He believed that compilers > > should normally initialize a character array to > > binary zero and so it shouldn't be a problem. > > In general if the array is 'on the stack', i.e. a local > variable within the scope of a function call, then the > variables are NOT initialized. > > Go ahead and take a look at the assembly output, if you > make sure you haven't omitted frame pointers, then you'll > see the compiler setup the frame pointer, and then > move the frame pointer by an amount equivalent to the > number of bytes of local variables. Variables in > the source are referenced then with respect to the > frame pointer. There is usually NO initialization > of these variables. Wow. Thanks for the prompt response. On monday I will indeed have a go at reading the assembly output. Can I just ask though whether if valgrind reporting this means that it is definitely uninitialized? I mean, if this error crops up again and again (which it probably will) if I *know* that valgrind reports it correctly then I can just tell people that they have a problem they must fix, and I don't need to bother with proving it by assembly. Cheers (and thanks again for replying so fast and so comprehensively) Ed |