Content deleted Content added
Ira Leviton (talk | contribs) m Replaced outdated html codes with wikicodes. |
Reverting edit(s) by 201.162.227.111 (talk) to rev. 1239272187 by Es20490446e: Vandalism (RW 16.1) |
||
(8 intermediate revisions by 7 users not shown) | |||
Line 1:
{{Short description|Computer code that is never executed}}
The term '''dead code''' has multiple definitions. Some use the term to refer to code (i.e. instructions in memory) which can never be executed at run-time.<ref>
In some areas of [[computer programming]], '''dead code''' is a section in the [[source code]] of a program which is executed but whose result 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),
While the result of a dead computation may never be used, it may raise [[Exception handling|exceptions]] or affect some global state, thus removal of such code may change the output of the program and introduce unintended [[software bug|bugs]]. Compiler optimizations are typically conservative in their approach to dead
== Example ==
Line 20:
== Analysis ==
[[Dead
The dead
In large programming projects, it is sometimes difficult to recognize and eliminate dead code, particularly when entire modules become dead. Test scaffolding can make it appear that the code is still live, and at times, contract language can require delivery of the code even when the code is no longer relevant.<ref>[[Douglas W. Jones]] [http://catless.com/Risks/8.19.html#subj2 Dead Code Maintenance, Risks 8.19 (Feb. 1, 1989)] {{Webarchive|url=https://web.archive.org/web/20110708124114/http://catless.com/Risks/8.19.html#subj2 |date=2011-07-08 }}</ref>
Line 30:
While most optimization techniques seek to remove dead code in an implementation, in extreme forms of optimization for size it may sometimes be desirable to deliberately introduce and carefully shape seemingly dead code, when it allows to fold otherwise unrelated code sections together (and thereby reduce their combined size) so that the extra code will effectively not harm the first path of execution through the code but is used to carry out the actions necessary for the alternative paths of execution, for which other sections of the code may become dead code. On a more functional level, this can be seen as both, artificially introduction of harmless/useful side-effects and reduction of the redundancy of the code, but it can also be used down to opcode level in order to allow the usage of shorter instructions, which would not be possible when folding code sequences without the concerted introduction of side-effects caused by the dead code.
== See also ==
* [[Dead
* [[Redundant code]]
* [[Unreachable code]]
* [[Oxbow code]]
* ''0xDEADC0DE'' is a [[Magic number (programming)#Debug values|
▲* ''0xDEADC0DE'' is a [[Magic number (programming)|Magic number]] written in [[Hexspeak]] used as a marker in [[OpenWrt|OpenWRT]] firmware
== References ==
{{Reflist}}
|