Menu ▾ ▴

FALSE NEGATIVE: Cppcheck misses dead stores across structured control flow

Rodri
2026-09-14
2026-09-15
  • Rodri

    Rodri - 2026-09-14

    Cppcheck 2.21.0 misses a scalar store that is never read before a switch completes. The minimal trigger contains no loop or continue.

    Affected tool and checker

    Cppcheck 2.21.0, unreadVariable / CheckUnusedVar liveness handling.

    Minimal reproducer

    void test(int input) {
      int value;
      value = 0;
      switch (input) {
      case 0:
        break;
      default:
        break;
      }
    }
    

    Reproduction command

    cppcheck --enable=all --inconclusive --check-level=exhaustive --std=c++17 \
      --template='{file}:{line}:{column}: [{id}] {message}' \
      mutant-cppcheck-unreadvariable-fn-switch-dead-store.cpp
    

    Current behavior

    Cppcheck emits no unreadVariable diagnostic for value.

    Expected behavior

    Cppcheck should report that the value assigned to value is never read.

     
  • CHR

    CHR - 2026-09-15
     

Log in to post a comment.