Rule 12.7 and underlying type - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17) +---- Forum: 6.12 Expressions (https://forum.misra.org.uk/forumdisplay.php?fid=39) +---- Thread: Rule 12.7 and underlying type (/showthread.php?tid=282) |
Rule 12.7 and underlying type - aravind - 30-06-2006 Hi, Question on 12.7: Bitwise operators shall not be applied to operands whose underlying type is signed [code]int32_T var1[32]; uint16_T var2 = 5U; int32_T var3 = var1[(var2 - 1) - misra-c - 22-08-2006 MISRA-C meeting 22-8-2006 The array index sub-expression Code: var2 - 1 The underlying type of a mixed signed / unsigned expression is undefined. In your second example, the array index sub-expression Code: var2 - 1U |