Cppcheck 2.21.0 misses a scalar store that is never read before a switch completes. The minimal trigger contains no loop or continue.
switch
continue
Affected tool and checker
Cppcheck 2.21.0, unreadVariable / CheckUnusedVar liveness handling.
Cppcheck 2.21.0
unreadVariable
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.
value
Expected behavior
Cppcheck should report that the value assigned to value is never read.
See https://trac.cppcheck.net/ticket/14405
Log in to post a comment.
Cppcheck 2.21.0 misses a scalar store that is never read before a
switchcompletes. The minimal trigger contains no loop orcontinue.Affected tool and checker
Cppcheck 2.21.0,unreadVariable/ CheckUnusedVar liveness handling.Minimal reproducer
Reproduction command
Current behavior
Cppcheck emits no
unreadVariablediagnostic forvalue.Expected behavior
Cppcheck should report that the value assigned to
valueis never read.See https://trac.cppcheck.net/ticket/14405