Jump to content

Unreferenced variable

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 208.138.31.76 (talk) at 18:15, 12 February 2008 (Examples). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

An unreferenced variable in the source code of a computer program is a variable that is defined but which is never used. This may result in a harmless waste of memory (unless the compiler used detects the situation and does not allocate for the variable, perhaps issuing a warning). Some coding guideline documents consider an unreferenced variable to be a potential symptom of a coding fault.

Examples

C:

 int main(void)
 {
   int i, j;
   for (i=0; i<10; i++)
      printf("%d", i);
   return 0;
 }

In this example, j is an unreferenced variable.