This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CGTools 7.4.1 - Warning 551-D not always generated?

Team,

Any comment for the following behavior for warning?

Compiling the code below with cgtools 7.4.1 doesn't generate a warning, although an uninitialized variable is used in line 7.
When line 4 is uncommented, a warning is generated, as expected.
command line is: cl6x.exe -c tmp.c

void fn(void)
{ int foo, bar, i;
  i = 10;
  //foo = bar; /* generates warning 551-D */
  do
  {
   foo = bar;  /* doesn't generate a warning */
   *(unsigned int *)i = foo;
  } while (--i);
}

Is there a particular reason why the statement in line 7 doesn't generate a warning?

Thanks and best regards,
Anthony

  • The following is distilled from a conversation between several TI'ers which unfortunately doesn't appear on the public forum.  Some of these words are mine, some aren't.

    The compiler will only catch the trivial obvious cases.  It is beyond the simple analysis capabilities of our compiler to detect this error.  As soon as the code becomes even slightly complicated (such as the presence of a loop), the compiler won't be able to trace every possible execution path, and some paths which leave variables uninitialized may be missed.

    To catch the more complex cases, use a static code analysis tool.  There are a variety of tools available; try starting at http://en.wikipedia.org/wiki/Static_code_analysis.

    There are also static code analyzers that will plug into CCS and will work with the TI compilers.  A web search for  "code composer static code analyzer" brings up Parasoft and Klocwork.  Coverity may also plug into CCS.