Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
15.7 and side effects
#1
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();
  }
}
<t></t>
#2
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
Posted by and on behalf of the MISRA C Working Group
#3
MISRA C:2012 TC1 (2016) added the note to R.15.7
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 2 Guest(s)