MISRA.STDLIB.LONGJMPUse of setjmp macro or longjmp function.
MISRA C 2012 Rule 21.4: The standard header file <setjmp.h> shall not be usedC90 [Unspecified 14; Undefined 64–67] C99 [Unspecified 32; Undefined 118–121, 173] [Koenig 74] Category: Required Analysis: Decidable, Single Translation Unit Applies to: C90, C99 AmplificationNone of the facilities that are specified as being provided by <setjmp.h> shall be used. Rationalesetjmp and longjmp allow the normal function call mechanisms to be bypassed. Their use may lead to undefined and unspecified behaviour. MISRA-C 2004 Rule 20.7 (required): The setjmp macro and the longjmp function shall not be usedUse of setjmp macro or longjmp function. This rule is also covered by MISRA.EXPANSION.UNSAFE. [Unspecified 14; Undefined 64—67, Koenig 74] setjmp and longjmp allow the normal function call mechanisms to be bypassed, and shall not be used. MISRA-C++ 2008 Rule 17-0-5 (required): The setjmp macro and the longjmp function shall not be used.This rule is also covered by MISRA.EXPANSION.UNSAFE. Rationalesetjmp and longjmp allow the normal function call mechanisms to be bypassed, and shall not be used, since exception handling provides a better defined mechanism for this. Example#include <setjmp.h> void f2 ( ); jmp_buf buf; void f1 ( ) { if ( !setjmp ( buf ) ) // Non-compliant { f2 ( ); } else { } } void f2 ( ) { longjmp ( buf, 10 ); // Non-compliant } |