Cppcheck 2.21.0 does not report a dead first store when its value is zero,
although the otherwise equivalent nonzero store is reported as redundantAssignment.
Cppcheck emits no redundantAssignment diagnostic. Replacing 0 with 42
produces redundantAssignment at the first assignment, isolating the
zero-value branch.
Expected behavior
Cppcheck should report that the first value assigned to value is overwritten
before it is read.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Cppcheck 2.21.0 does not report a dead first store when its value is zero,
although the otherwise equivalent nonzero store is reported as
redundantAssignment.Affected tool and checker
Cppcheck 2.21.0,redundantAssignment.Minimal reproducer
Reproduction command
Current behavior
Cppcheck emits no
redundantAssignmentdiagnostic. Replacing0with42produces
redundantAssignmentat the first assignment, isolating thezero-value branch.
Expected behavior
Cppcheck should report that the first value assigned to
valueis overwrittenbefore it is read.
There is a deliberate bailout to allow "trivial" initialization.