[previous] 2962 [next] Apparent: Using value of uninitialized automatic object '%s'.
Unset data

An apparent anomaly has been detected. Preceding operations imply that this object will sometimes be uninitialized and its value may therefore be undefined.

For example, in the code shown below, the value of i will only be initialized if the value of n is greater than 0. However the presence of the "if" statement implies that this will not always be true. Of course, if the value of n is always greater than zero, the value of i will always be initialized; but this would imply that the "if" statement is redundant and any code contained in the "if" block should be moved to the outer block.


/*PRQA S 2017,2983,2986,3120,3199,3203,3227,3347,3408 ++*/

void foo(int n)
{
   int  i;
   int  j;

   if (n > 0)
   {
      i = 1;
   }

   j = i + 2;              /* 2962 */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents