MISRA Discussion Forums
Rule 7.0.5: add exception for modulo operand - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=188)
+---- Forum: 4.7 Standard conversions (https://forum.misra.org.uk/forumdisplay.php?fid=193)
+---- Thread: Rule 7.0.5: add exception for modulo operand (/showthread.php?tid=1788)



Rule 7.0.5: add exception for modulo operand - dunno - 02-12-2026

As I understand this code is non-compliant:
Code:
u8a % u8b

I wonder if some exception would be acceptable such as:
modulo and bitand operations are compliant when both operands are unsigned. the result shall be considered to be unsigned.

That would make such code compliant:
Code:
  if ((u8a % u8b) == 0U)