Hi, I found a false negative in Cppcheck 2.21.0 and 2.22 dev when a local lambda object is initialized but never read.
Affected tool
Cppcheck 2.21.0; also reproduced with Cppcheck 2.22 dev
Affected checker
Cppcheck unreadVariable
Minimal reproducer
void test(int value) { auto callback = [value] {}; }
Reproduction command
cppcheck --version cppcheck --enable=style --inconclusive --std=c++17 --checkers-report=checkers.txt --template='{file}:{line}:{column}: [{id}] {message}' cppcheck-unreadvariable-fn-lambda.cpp
Current behavior
Cppcheck produces no unreadVariable, unusedVariable, or redundantAssignment diagnostic.
unreadVariable
unusedVariable
redundantAssignment
Expected behavior
Cppcheck should report line 2 because the value assigned to callback is never read.
callback
See https://trac.cppcheck.net/ticket/12957
Log in to post a comment.
Hi, I found a false negative in Cppcheck 2.21.0 and 2.22 dev when a local lambda object is initialized but never read.
Affected tool
Cppcheck 2.21.0; also reproduced with Cppcheck 2.22 devAffected checker
Cppcheck unreadVariableMinimal reproducer
Reproduction command
Current behavior
Cppcheck produces no
unreadVariable,unusedVariable, orredundantAssignmentdiagnostic.Expected behavior
Cppcheck should report line 2 because the value assigned to
callbackis never read.See https://trac.cppcheck.net/ticket/12957