Content deleted Content added
No edit summary |
No edit summary |
||
Line 1:
'''Dead code''' is a [[computer programming]] term for code in the [[source code]] of a program which is executed but whose results is never used in any other computation. <ref>[http://doi.acm.org/10.1145/349214.349233 Debray, S. K., Evans, W., Muth, R., and De Sutter, B. 2000. Compiler techniques for code compaction. ACM Trans. Program. Lang. Syst. 22, 2 (Mar. 2000), 378-415.]</ref> The execution of dead code wastes time as its results are never used. Dead code is not equivalent to [[unreachable code]], which is code that can never be executed.
#REDIRECT [[Unreachable code]]▼
Dead code elimination is a form of [[compiler optimization]] in which dead code is removed from a program. The dead code elimination technique is in the same class of optimizations as [[unreachable code]] elimination and [[redundant code]] elimination.
While the result of a dead computation may never be used the dead code may raise [[exceptions]] or affect some global state thus removal of such code may change the output of the program and should not be performed. Compiler optimizations are typically conservative in their approach to dead code removal if there is any ambiguity as to whether removal of the dead code will affect the program output.
== Example ==
<source lang='c'>
int f (int x, int y)
{
int z = x + y;
return x * y;
}
</source>
In the above example the definition of <tt>z</tt> is never used and is thus dead code and can be removed.
==See also==
*[[Redundant code]]
==References==
{{reflist}}
* <cite>Appel, A. W. 1998 Modern Compiler Implementation in Java. Cambridge University Press. </cite>
[[Category:Software engineering terminology]]
[[Category:Software metrics]]
[[Category:Source code]]
|