27-03-2015, 01:28 PM
Consider the following example: In this example the call of "fn(-3)" never executes the code "y=x" and therefore no persistent side effect will occur.
Is this a violation of rule 13.5?
Code:
bool fn ( int x )
{
static int y;
if ( x > 0 )
{ y = x; } /* causes persistent side effect if reached */
return ....
}
void call ( bool flag )
{
if ( flag && fn(-3) ) /* Does RHS contain persistent side effect ? */
{ .... }
}
Is this a violation of rule 13.5?
Posted by and on behalf of the MISRA C Working Group