Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 3-4-1 issues
#2
This program is equivalent and compliant. Result has to be declared outside the loop, as the value in loop n+1 depends upon the value in loop n, so Result cannot be inside the body of the loop

Code:
void f ( void )
{
  int Result = 0;
  
  for ( int Index = 0; Index < 10; Index++ )
  {
    Result += SomeTestFunction( );
    
    if ( Result > 5 )
    {
      break;
    }
  }
}
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)