On Thu, Nov 26, 2009 at 8:24 PM, Stewart Smith <[email protected]> wrote:
> The second and third printf calls here get a valgrind warning.
>
> First printf:
> ==18960== Use of uninitialised value of size 8

> ==18960== Conditional jump or move depends on uninitialised value(s)

Valgrind diagnoses places where uninitialized data is used in some way
that could have a side effect or alter the control flow.

Newer versions of Valgrind have an option that you should use:

 --track-origins

Just like Valgrind tracks the origins of which call stack allocated
some misused memory, it also tracks the origin of some uninitialized
value. This could help you quickly find the answer.

It's possible that the uninitialized value originated quite far away
from where it is manifested.

Valgrind doesn't show uninitialized uses right at the origin because
that would lead to false
positives. For instance, structures have gaps in them which are left
uninitialized sometimes.
Or what if you are using unions?

  union u { char big_array[256]; short little_int; }

If you make an instance of u, and initialize the ``little_int''
member, that leaves most of the big_array space uninitialized (perhaps
254 bytes out of 256). You can assign one such union to another; that
is well-defined C code:

  union u a, b;
  a.little_int = 42;

  b = a; /* b.little_int is 42 now, perfectly valid */

So at this line b = a, a whole lot of uninitialized bits get copied.
We don't want valgrind to be bothering us with that.  But the
``undefinedness'' of those bits gets copied along with them.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to