In computer programming, dead code typically consists of blocks of programming instructions or entire routines that will never be accessed because all calls to them have been removed, or code that cannot be reached because it is guarded by a control structure that must always transfer control somewhere else. Some generalize the idea of dead code to any code that can be safely removed without causing an error, such as a definition which is never used. Wikibooks has more about this subject: Computer programming Computer programming (often simply programming) is the craft of implementing one or more interrelated abstract algorithms using a particular programming language to produce a concrete computer program. ...
The presence of dead code may reveal either logical errors due to alterations in the program or significant changes in the assumptions and environment of the program (see also software rot); a good compiler should report dead code so a maintainer can think about what it means. Many times dead code is inserted by a defensive programmer as Assertion Code for tests that really can't happen (yet). Other times dead code is inserted by the programmer for debugging purposes but has yet to be removed. Software Rot, also known as Software Decay comes in two forms; Dormant Rot. ... Assertion Code is computer code that tests for situations that cannot happen, or really should not happen. ...
Before removing apparently 'dead' code, a programmer must be satisfied that it really is dead. This is easier on short pieces but more difficult on long sections where the function it performs is not clear. Thus much dead code remains and its removal by the compiler is important.
Deadcode means unnecessary, inoperative code that can be – and should be – removed.
The deadcode may not have been tested thoroughly and it may contain bugs that are hard to detect.
Since deadcode detection is a delicate process that requires absolute certainty of the deadness status, developers should only use a tool specifically designed to read source code to find the unused parts.
In compiler theory, deadcode elimination is a compiler optimization used to reduce program size by removing code which can never be executed (known as dead or unreachable code).
A common use of deadcode elimination is as an alternative to optional code inclusion via a preprocessor.
This technique is common in debugging to optionally activate blocks of code; using an optimizer with deadcode elimination eliminates the need for using a preprocessor to perform the same task.