Hi, I found a false negative in Cppcheck 2.21.0 and 2.22 dev when an assignment's expression value is returned but the value stored in the local variable is never read.
Affected tool
Cppcheck 2.21.0; also reproduced with Cppcheck 2.22 dev
Cppcheck should report line 5 because the assignment expression supplies the return value directly and the value stored in value is never read from the variable.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I found a false negative in Cppcheck 2.21.0 and 2.22 dev when an assignment's expression value is returned but the value stored in the local variable is 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
unreadVariablediagnostic.Expected behavior
Cppcheck should report line 5 because the assignment expression supplies the return value directly and the value stored in
valueis never read from the variable.Thanks for reporting, example added here: https://trac.cppcheck.net/ticket/11222