CWARN.BOOLOP.INC
Attempt to increment a Boolean value
The CWARN.BOOLOP.INC checker finds attempts to increment or decrement a Boolean value.
Vulnerability and risk
Using increment or decrement operations with a Boolean true/false value has no effect.
Vulnerable code example
Copy
#include <iostream>
using namespace std;
void foo() {
bool b = true;
b++;
}
int main() {
foo();
return 0;
}
Klocwork flags the attempt to increment Boolean variable 'b' at line 5.