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. code in a function that is only called from another function that is only called to handle certain input that never occurs in practice.

Determining that some 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 it may perform dead code elimination.

[Jargon File]

Last updated: 2018-08-19

Nearby terms:

deadDEADBEEFdead codedead code eliminationdeadlockdeadly embrace

Try this search on Wikipedia, OneLook, Google


Loading