Skip to main content
Sigvex

Dead Code Remediation

How to handle unreachable code: remove it, or restore the path that was supposed to reach it.

Dead Code Remediation

Overview

Related Detector: Dead Code

Unreachable code — a branch no input can reach, a function no path calls, a statement after an unconditional return/revert — bloats bytecode and, more importantly, can hide a logic error: the guard that was supposed to reach it is wrong. The remediation is to determine whether the code should be reachable, then either restore the path or remove the code.

Before (Vulnerable / misleading)

function claim() external {
    if (paused) {
        revert("Paused");
        emit Claimed(msg.sender);   // unreachable — after revert
    }
    _payout(msg.sender);
    // A whole helper below is never called from anywhere.
}

After (Fixed — remove, or fix the reaching path)

function claim() external {
    require(!paused, "Paused");   // clear guard, no unreachable tail
    _payout(msg.sender);
    emit Claimed(msg.sender);
}

If the dead branch encodes intended behaviour (e.g. an emergency path), fix the condition that was meant to reach it rather than deleting it. If it is genuinely obsolete, remove it so the deployed bytecode reflects the real logic.

Common Mistakes

  • Deleting an unreachable emergency branch that was dead only because a guard was mis-wired.
  • Leaving unreferenced internal functions in place, enlarging the attack surface a reviewer must reason about.
  • Treating dead code as purely cosmetic; unreachable-after-revert statements often mark a real control-flow mistake.

References