MISRA.FUNC.RECURRecursive function. MISRA C 2012 Rule 17.2: Functions shall not call themselves, either directly or indirectlyCategory: Analysis Analysis: Undecidable, System Applies to: C90, C99 RationaleRecursion carries with it the danger of exceeding available stack space, which can lead to a serious failure. Unless recursion is very tightly controlled, it is not possible to determine before execution what the worst-case stack usage could be. MISRA-C 2004 Rule 16.2 (required): Functions shall not call themselves, either directly or indirectly.Recursive function. This means that recursive function calls cannot be used in safety-related systems. Recursion carries with it the danger of exceeding available stack space, which can be a serious error. Unless recursion is very tightly controlled, it is not possible to determine before execution what the worst-case stack usage could be. MISRA-C++ 2008 Rule 7-5-4 (advisory): Functions should not call themselves, either directly or indirectly.RationaleUnbounded recursion is likely to lead to a stack over-flow and may impact system timings. This is also the case for an iterative algorithm. Exampleint32_t fn ( int32_t x ) { if ( x > 0 ) { x = x * fn ( x — 1 ); // Non-compliant } return ( x ); } // File1.cpp int32_t fn_2 ( int32_t x ) { if ( x > 0 ) { x = x * fn_3 ( x — 1 ); // Non-compliant } return ( x ); } // File2.cpp int32_t fn_3 ( int32_t x ) { if ( x == 0 ) { x = x * fn_2 ( x — 1 ); // Non-compliant } return ( x ); } |