MISRA Discussion Forums

Full Version: 15.7 and side effects
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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();
  }
}
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