Code that is never executed is known as dead code. Typically, the presence of dead code indicates that a logic error has occurred as a result of changes to a program or the program's environment. To improve readability and ensure that logic errors are resolved, dead code should be identified, understood, and eliminated.
Noncompliant Code Example
This noncompliant code example contains code that cannot possibly execute.
This compliant solution makes the dead code reachable.
The presence dead code may indicate logic errors that can lead to unintended program behavior. As a result, resolving dead code can be an in-depth process requiring significant analysis.
|SEI CERT C Coding Standard||MSC07-C. Detect and remove dead code|
|SEI CERT C++ Coding Standard||VOID MSC07-CPP. Detect and remove dead code|
|[CPAN]||Elliot Shank, Perl-Critic-1.116 Subroutines::ProhibitUnusedPrivateSubroutines, Variables::ProhibitUnreachableCode|