Use compiler options to initialize dynamically with unusual or invalid values those local (stack) variables that aren’t explicitly initialized.
Reveal uninitialized variables that need to be initialized.
Which local variables are getting random values that are being used in computation?
Where is the first place that the random values are being used?
Computations may not fail with the values assigned.
Initialize floating-point variables to IEEE NaN, pointer variables to an invalid address, and integer variables to the maximum representable integer.
Add code to assign values to all local variables.
Run the program on a different system, where 0 isn’t a valid address.
Use the refined tactic when your compiler doesn’t support an option for the basic tactic.
Use basic or related tactics when any of the following is true:
A bug occurs when the program is run standalone, but not when it’s run under a debugger.
A bug occurs when the program is run under one user account and environment, but not when it’s run under another.
Use this tactic at least once before the program is put into production, as an additional testing strategy.
C++: Initializing all local pointer variables is cheap insurance.
Java: Java requires the programmer to initialize local variables, so the tactic is unnecessary.
C: Initializing all local pointer variables is cheap insurance.
Fortran: Use initializers to ensure local variables have values.