Rule 18.4 using -- operator for pointers - 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:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21) +---- Forum: 8.18 Pointers and arrays (https://forum.misra.org.uk/forumdisplay.php?fid=173) +---- Thread: Rule 18.4 using -- operator for pointers (/showthread.php?tid=1078) |
Rule 18.4 using -- operator for pointers - simondl - 17-07-2014 Dear Rule 18.4 mentions +, -, += and -= operators and also ++ operator (both post and pre fix?). -- operator is not mentioned. How to deal with it? Regards Re: Rule 18.4 using -- operator for pointers - misra-c - 11-08-2014 Rule 18.4 prohibits the use of "+, -, +=, -=" operators on expressions with a pointer type. All other operators that are legal C do not violate this rule. This includes ++ and --, both prefix and postfix. The rationale mentions the ++ operator as an example of a valid operator that is not restricted by this rule. It was not intended that the rationale should list all valid operators. As a general point, it should be remembered that the rationale section is not normative. Only the guideline headline and amplification (where present) are intended to specify which operators the guideline applies to. |