Dead code
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.
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.
References
- ^ "Hongwei Xi, Dead Code Elimination through Dependent Types" (PDF) . Archived from the original (PDF) on 2012-03-10 . Retrieved 2020-05-06 . Wikipedia revision 1325383945, retrieved 2026-11-21 · 1588719600.0
- ^ [1] Archived 2020-05-20 at the Wayback Machine DO-178B Wikipedia revision 1325383945, retrieved 2026-11-21 · 1795215600.0
- ^ DO-178B Wikipedia/DO-178B. Wikipedia revision 1325383945, retrieved 2026-11-21 · 1795215600.0
- ^ 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. Wikipedia revision 1325383945, retrieved 2026-11-21 · 1795215600.0
- ^ Appel, A. W. 1998 Modern Compiler Implementation in Java. Cambridge University Press. Wikipedia revision 1325383945, retrieved 2026-11-21 · 1795215600.0
- ^ Douglas W. Jones Dead Code Maintenance, Risks 8.19 (Feb. 1, 1989) Archived 2011-07-08 at the Wayback Machine Wikipedia revision 1325383945, retrieved 2026-11-21 · 1795215600.0
- ^ Habib Heydarian, Microsoft Corp Wikipedia revision 1325383945, retrieved 2026-11-21 · 1795215600.0
- ^ Eclipse Developer Guide Wikipedia revision 1325383945, retrieved 2026-11-21 · 1795215600.0
- Hongwei Xi, Dead Code Elimination through Dependent Types . · 1764630000.0
- [http://www.do178site.com/do178b_questions.php] Webarchive|url=https://web.archive.org/web/20200520200130/http://www.do178site.com/do178b_questions.php |date=2020-05-20 DO-178B . · 1764630000.0
- [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–41 . · 1764630000.0
- 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 . · 1764630000.0
- [http://blogs.msdn.com/b/habibh/archive/2009/07/31/discover-dead-code-in-your-application-using-code-analysis.aspx Habib Heydarian, Microsoft Corp] . · 1764630000.0
- [http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm Eclipse Developer Guide] . · 1764630000.0
Cite this
"Dead code". 1764704130. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1325383945