11-10-2016, 09:25 AM
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
the MISRA C++ Working Group