| View previous topic :: View next topic |
| Author |
Message |
tsalem
Joined: 25 Mar 2010 Posts: 22
|
Posted: Tue Mar 30, 2010 1:51 pm Post subject: 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. |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 5001 Location: The Portland Group Inc.
|
Posted: Tue Mar 30, 2010 3:26 pm Post subject: |
|
|
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 (www.valgrind.org).
- Mat |
|
| Back to top |
|
 |
Malcolm Bibby
Joined: 16 Nov 2009 Posts: 28
|
Posted: Wed Mar 31, 2010 7:25 am Post subject: |
|
|
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?
Thanks
Malcolm Bibby |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 5001 Location: The Portland Group Inc.
|
Posted: Wed Mar 31, 2010 8:29 am Post subject: |
|
|
Hi Malcolm,
Suppression files are application dependent so I don't use them.
Sorry,
Mat |
|
| Back to top |
|
 |
Malcolm Bibby
Joined: 16 Nov 2009 Posts: 28
|
Posted: Wed Mar 31, 2010 8:44 am Post subject: |
|
|
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/libpgf90.so)
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.
Thanks
Malcolm |
|
| Back to top |
|
 |
|