dead code

<programming>

(Or "infeasible path") Any part of a program that can never be executed because no control flow path leads to it. This may be because it is guarded by a control structure that will always transfer control somewhere else, e.g.

  if (false)
  {
    # dead code
  }

or it may be for a less obvious, less local reason, e.g. a function that is only called to handle input that never occurs.

Determining that code is dead may thus require analysis of the whole program. Consideration of possible inputs is probably beyond the normal (static) identification of dead code.

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). Sometimes it simply represents can't happen tests inserted by a defensive programmer.

A good compiler should warn about dead code or simply ignore it (dead code elimination).

The presence of dead code may reduce reported test coverage since in most cases no unit test will exercise the code.

[Jargon File]

Last updated: 2020-01-31

Nearby terms:

deadDEADBEEFdead codedead code eliminationdeadlockdeadly embrace

Try this search on Wikipedia, OneLook, Google


Loading