Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 10.1 Small integer type operands of bitwise operators
#2
You are correct in saying that small unsigned types are promoted to a "signed int" standard type, but have an essentially unsigned type. This means that ~ on unsigned types is allowed by MISRA-C:2012, yet would produce different values depending on whether your implementation is one’s or two’s bit complement implementation.

This is only an issue if the resultant value is treated as a signed value, otherwise the bit pattern is consistent with what a user would expect. Any attempt to use the value of the result in an essentially signed context will produce a violation of rule 10.1, 10.3 or 10.4.
Posted by and on behalf of the MISRA C Working Group


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)