|
From: Nghia Ho <ngh...@ya...> - 2012-12-12 09:59:28
|
Hi all,
I've come across a lot of code at work where an unitialized variable is passed around to different variables and only detected at a much later time when it actually gets used. Even with track-origin=yes it doesn't tell me exactly where the variable is, still have to hunt more. Having noticed that valgrind does checks when there is an if statement, I ended doing a lot of this kind of hack to find the culprit:
int a; // never initialized
.....
int b = a; if(a) { int dummy = 1; }
Valgrind will then tell me the exact line where the unitialized variable is used, and then I keep going backwards adding more of those if(...) test. Is there a better way? I'm hoping there's some option that can tell Valgrind to check on assignments for unitialized variables as well.
Nghia |