MISRA Discussion Forums
15.7 and side effects - 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.15 Control flow (https://forum.misra.org.uk/forumdisplay.php?fid=170)
+---- Thread: 15.7 and side effects (/showthread.php?tid=1217)



15.7 and side effects - lovewar - 11-12-2015

Would the following examples be compliant with rule #15.7?
Code:
void R_15_7 ( void ) {
   bool_t flag_1 = get_bool ( );
   bool_t flag_2 = get_bool ( );
   if ( flag_1 )  {
      action_f1 ( );
   }
   else if ( flag_2 )  {
      action_f2 ( );
   }
   else {  // here , is the "else" compliant ?
      persistent_side_effects();
  }
}

Would the following examples be compliant with rule #15.7?
Code:
void R_15_7 ( void ) {
   bool_t flag_1 = get_bool ( );
   bool_t flag_2 = get_bool ( );
   if ( flag_1 )  {
      action_f1 ( );
   }
   else if ( flag_2 )  {
      action_f2 ( );
   }
   else {  // here , is the "else" compliant ?
      side_effects();
  }
}

Would the following examples be non-compliant with rule #15.7?
Code:
void R_15_7 ( void ) {
   bool_t flag_1 = get_bool ( );
   bool_t flag_2 = get_bool ( );
   if ( flag_1 )  {
      action_f1 ( );
   }
   else if ( flag_2 )  {
      action_f2 ( );
   }
   else {  // here, is the "else" non-compliant ?
      no_side_effects();
  }
}



Re: 15.7 and side effects - misra-c - 18-02-2016

In a number of rules such as 13.3 and 13.6, the amplification explicitly states
Quote: A function call is considered to be a side effect for the purposes of this rule.

This amplification should also apply to this rule and will be corrected in the future.

Therefore all your examples are considered to be compliant with Rule 15.7


RE: 15.7 and side effects - misra-c - 02-07-2024

MISRA C:2012 TC1 (2016) added the note to R.15.7