|
From: Dave N. <dc...@us...> - 2006-02-16 17:32:42
|
OK, I see now what is going on. valgrind treats global data as initialized but my test program assigned an uninitialized variable to the global variable that was used in the return. Thanks for the reply! John Reiser wrote: > Dave Nomura wrote: > >>I was creating an example for a valgrind ppc demo and was surprised to >>see that a dereference of an uninitialized global data variable did not >>result in an error from valgrind, but when the same variable was >>propagated to exit() via the return value of main() the error was >>detected. Is this a bug or am I misunderstanding what should be >>happening? > > > Global data is always initialized; it can never be uninitialized > except via explicit copying from some other uninitialized data. > > If the source code contains no explicit initialization: > int foo; /* at top level (file scope) */ > then as far as guaranteed values are concerned it is equivalent to: > int foo = 0; > The first case (no explicit initialization) resides in .bss > which is cleared to zero upon instantiation by the kernel or by > the runtime module loader ld-linux.so. The second case (explicit > initialization) resides in .data, except that some recent compiler > tools put explicit initialization to 0 into .bss because in many > cases it is an optimization (of space in the filesystem). However, > the behavior with respect to data caches at runtime might be different. > |