hi, with the following code:
#include <stdbool.h> // cppcheck-suppress unusedFunction bool fun(const int input, const int input_b) { bool ret = true; switch (input) { case 1: ret = false; if (!input_b) break; ret = true; break; } return ret; }
i get a redundantAssignment warning:
file.c:39:17: style: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment] ret = true; ^ file.c:36:17: note: ret is assigned ret = false; ^ file.c:39:17: note: ret is overwritten ret = true; ^
which i believe is a false positive.
thanks, jacob
Oddly, the warning disappears when replacing true and false with integers 1 and 0, respectively.
true
false
Thanks! I have created ticket https://trac.cppcheck.net/ticket/10058
Log in to post a comment.
hi,
with the following code:
i get a redundantAssignment warning:
which i believe is a false positive.
thanks, jacob
Oddly, the warning disappears when replacing
true
andfalse
with integers 1 and 0, respectively.Thanks! I have created ticket https://trac.cppcheck.net/ticket/10058