What is unreachable code?
Unreachable code, a part of the source code that will never be executed due to inappropriate exit points/control flow. The other kind of unreachable code is referred as dead code, although dead code might get executed but has no effect on the functionality of the system.
Below example clearly shows unreachable code and dead code differences:
Unreachable Code Side Effects:
Unnecessary memory overheads.
Unnecessary caching cycles which leads to performance bottlenecks.
Documenting and Maintaining overheads.
Unreachable Code Causes:
Programming errors while developing complex conditional branches.
Incomplete unit testing because of which unreachable code was undetected.
Redundant code that developer forgot to delete
The code that might be programmatically correct but won't be executed at any point of time due to the input data that is passed to the function.