MISRA Discussion Forums
12.4 and Non-Returning Functions - 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: 12.4 and Non-Returning Functions (/showthread.php?tid=312)



12.4 and Non-Returning Functions - gs - 03-10-2006

Hi,
12.4 prohibits side-effects on the right hand side of '&&' or '||'. What if, on the right hand side, I place a function with no side-effects, provided it returns, but which does contain side-effects if it does not return (e.g., an assertion which writes to a log file of some sort)? Is such a function allowed on the right hand side of the logical operators?


- misra-c - 21-11-2006

MISRA-C Steering Team - 7th November 2006

Non-returning is considered to be a side effect, because it changes the program control flow.
If a function has any conditional side effect, then it is considered to have a side effect. It would therefore not be allowed by this rule