Back to all issues

Issue 4181

Bug: Bitwise negation always overflows for types "unsigned char" and "unsigned int."


SubmittedProductStatus
2019-01-25Reactis for CResolved in 2018.0.1 (released Jun 14, 2019; release notes)

The rules for flagging unsigned integer overflows need to be adjusted for the bitwise negation operation. For example, under the current rules, the following will always overflow:

  unsigned char x = 0;
  x = ~x;
The last statement is flagged as an overflow because x is promoted to type "int" prior to negation, which results in a value which will not fit within a container of type "unsigned char."