There is a problem with analyzer that a wrong value is given when modeling the increment operator of the operand with type bool. After rL307604 is applied, a unsigned overflow may occur.
Example:
void func() {
bool b = true;
// unsigned overflow occur, 2 -> 0 U1b
b++;
}The use of an operand of type bool with the ++ operators is deprecated but valid untill C++17. And if the operand of the increment operator is of type bool, it is set to true.
This patch includes two parts:
- If the operand of the increment operator is of type bool or type _Bool, set to true.
- Modify BasicValueFactory::getTruthValue(), use getIntWidth() instead getTypeSize() and use unsigned instead signed.