Is a function parameter “used†if cast to void? - 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.2 Unused code (https://forum.misra.org.uk/forumdisplay.php?fid=157) +---- Thread: Is a function parameter “used†if cast to void? (/showthread.php?tid=1113) |
Is a function parameter “used†if cast to void? - misra-c - 09-10-2014 Does the following violate rule 2.7 (There should be no unused parameters in functions)? Code: void fn ( int32_t param ) Re: Is a function parameter “used†if cast to void? - misra-c - 09-10-2014 param is an operand of the cast operator and so is "used" according to the definition of “used†in Appendix J. Therefore this code does not violate rule 2.7. This is consistent with the exception to rule 2.2 on dead code, which states “ A cast to void is assumed to indicate a value that is intentionally not being used.†|