MISRA-C:2012 warning of Rule 10.8 “being cast to a wider type”
问题 I got a MISRA-C warning of Rule 10.8: A composite expression of 'essentially unsigned' type (unsigned char) is being cast to a wider unsigned type, 'unsigned short'. This warning was detected with the following code. void Fucntion(unsigned char isSwitchOn) { unsigned short switchMask = 0U; switchMask |= (unsigned short)(isSwitchOn & 1U) << 1; Why was a warning detected? Also, does this code cause problems? I think that the expression (isSwitchOn & 1U) is converted to an int type and