I have a piece of code like this:
int isUpperBound = ((j == 1) ^ (spacing[i] < 0));
and cppcheck 1.74 started warning:
"Boolean result is used in bitwise operation. Clarify expression with parentheses"
What additional parens could I add? What is this warning trying to tell me really?
Thanks,
Sean
The check became too noisy, we know this and will fix it somehow for next release.
It seems unfixed in 1.75.
worksforme:
daniel@raspberrypi:~/cppcheck $ ./cppcheck --enable=style ../a.c Checking ../a.c ... [../a.c:3]: (style) Variable 'isUpperBound' is assigned a value that is never used. daniel@raspberrypi:~/cppcheck $ ./cppcheck --version Cppcheck 1.75 daniel@raspberrypi:~/cppcheck $ cat ../a.c void f() { int isUpperBound = ((j == 1) ^ (spacing[i] < 0)); }
I've just revisited this in 1.76.1 and indeed it's basically fixed. I have only one case left:
bool foundProperty = ... if (!foundProperty ^ (sliceOrder == 3))
I can workaround it with:
if ((!foundProperty) ^ (sliceOrder == 3))
I guess it's debatable if this should be considered a false positive or not...
The warning seems completely applicable there.
Log in to post a comment.
I have a piece of code like this:
int isUpperBound = ((j == 1) ^ (spacing[i] < 0));
and cppcheck 1.74 started warning:
"Boolean result is used in bitwise operation. Clarify expression with parentheses"
What additional parens could I add? What is this warning trying to tell me really?
Thanks,
Sean
The check became too noisy, we know this and will fix it somehow for next release.
It seems unfixed in 1.75.
worksforme:
I've just revisited this in 1.76.1 and indeed it's basically fixed. I have only one case left:
I can workaround it with:
I guess it's debatable if this should be considered a false positive or not...
The warning seems completely applicable there.