AutosarC++19_03-M5.0.20

Non-constant operands to a binary bitwise operator shall have the same underlying type

Required inputs: IR

Rationale

Using operands of the same underlying type documents that it is the number of bits in the final (promoted and balanced) type that are used, and not the number of bits in the original types of the expression.

Example
uint8_t  mask = ~(0x10); 
uint16_t value;
value ^= mask; // Non-compliant

The intent may have been to invert all bits except for bit 5, but the top 8 bits will not have been inverted.

Note

For legal reasons, this rule’s description is not part of the public documentation.