Detecting uninitialized variables

Is there any way, through a compiler option or within the debugger, to initialize program variables in order to detect usage of uninitialized variables.

Some compilers have an option to set all variables to NaN or some such value. That way, when variables are used without having been initialized, the program terminates.

Hi tsalem,

The flag “-Msave”, which applies the SAVE attribute to all local variables, has a side effect of initializing variables to zero. Though, the best method I’ve found to detect UMRs is to use Valgrind (

  • Mat

Good morning Mat.

I picked up on your favorable comment about Valgrind and have downloaded it. Do you have any suppression files that you have added for when you use it? If so, would you mind sharing them with me?


Malcolm Bibby

Hi Malcolm,

Suppression files are application dependent so I don’t use them.


Mat, I used valgrind on my code that breaks with -gopt -O2.

Using memcheck, I get 7 contexts where valgrind reports an error. The message is:

Conditional jump or move depends on uninitialised value(s)
at 0x71C53ED: pgf90_trim (in /opt/pgi/linux86-64/10.3/libso/

In each case, I have printed out the argument to trim to be sure it is there and what I expect. It is.

The other 2 contexts look like they might lead me to the problem in my code.

Would you please respond to the error message above.



Sorry Malcom, I’m not sure. What’s the source line look like and what types of arguments are you passing in?

  • Mat