unreferenced variable

{{Short description|Variable which is defined but never used}}

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. Many compilers detect such variables and do not allocate storage for them (i.e., "optimize away" their storage), generally also issuing a warning as they do.{{Cite book |last1=Blair-Chappell |first1=Stephen |url=https://books.google.com/books?id=n3DtR4mQNmwC |title=Parallel Programming with Intel Parallel Studio XE |last2=Stokes |first2=Andrew |date=2012-04-19 |publisher=John Wiley & Sons |isbn=978-1-118-23488-4 |pages=108 |language=en}}

Some coding guideline documents consider an unreferenced variable to be a symptom of a potential coding fault. On the other hand, unreferenced variables can be used as temporary placeholders to indicate further expected future developments in the code.

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.

References

{{Reflist}}

{{DEFAULTSORT:Unreferenced Variable}}

Category:Variable (computer science)

{{Compu-prog-stub}}