AutosarC++19_03-M17.0.5¶
The setjmp macro and the longjmp function shall not be used
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
setjmp 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
}
Note
For legal reasons, this rule’s description is not part of the public documentation.