Dead code
The term dead code has multiple definitions.
≈ 2 min read
Dead code. encyclopegia.org, snapshot enwiki-001325383945. /a/dead-code
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
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. 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.
The execution of dead code wastes computation time and memory. While the result of a dead computation may never be used, it may raise exceptions or affect some global state, thus removal of such code may change the output of the program and introduce unintended bugs.
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. The programmer may aid the compiler in this matter by making additional use of static and/or inline functions and enabling the use of link-time optimization. int foo(int x, int y) { int z = x / y; return x * y; } In the C code above example, although the division of x by y is computed and never used, it will raise a (floating point exception signal) when a division-by-zero occurs.
Therefore, the removal of the dead code may change the output of the program.
Text derived from https://en.wikipedia.org/w/index.php?oldid=1325383945 under CC BY-SA 4.0; modifications have been made.