12.4 and Non-Returning Functions

6.12 Expressions

Moderators: misra-c, david ward

Locked
gs
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

12.4 and Non-Returning Functions

Post by gs » Tue Oct 03, 2006 2:33 pm

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
Posts: 566
Joined: Thu Jan 05, 2006 1:11 pm

Post by misra-c » Tue Nov 21, 2006 3:16 pm

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
---
Posted by and on behalf of
the MISRA C Working Group

Locked

Return to “6.12 Expressions”