/* >>>------------------------------------------------------------ * * File: rule_17.6.c, Module: M2CM-3.2-QAC-8.1.2 * * RULE 17.6 (Required): * The address of an object with automatic storage shall not be * assigned to another object that may persist after the first object * has ceased to exist. * * Implemented by messages: * 3217 Address of automatic object exported to a pointer with * linkage or wider scope. * * 3225 Address of automatic object exported using a function * parameter. * * 3230 Address of automatic object assigned to local pointer * with static storage duration. * * 4140 Address of automatic object exported in function return * value. * * <<<------------------------------------------------------------ */ /* PRQA S 2983,3203 ++ */ #include "misra.h" #include "m2cmex.h" static S16 * test_1706a( S16 **ppi ); extern S16 test_1706( void ) { S16 *pi1; S16 *pi2; pi1 = test_1706a( &pi2 ); *pi1 = 1; /* Undefined behaviour */ *pi2 = 2; /* Undefined behaviour */ return 1; } static S16 * test_1706a( S16 **ppi ) { static S16 * pc1706; S16 *p; S16 c = 0; { S16 i = 1; p = &i; /* MISRA Violation */ } pc1706 = &c; /* MISRA Violation */ *ppi = &c; /* MISRA Violation */ return &c; /* MISRA Violation */ }