![]() |
|
MISRA C:2012 Rule-18.6: (Required) |
|
||||
![]() | |||||||
Amplification:
The address of an object might be copied by means of:
Example Code:
#pragma PRQA_MESSAGES_OFF 2983
#include "misra.h"
#include "m3cmex.h"
static int16_t * rule_1806a( int16_t **ppi );
extern int16_t rule_1806( void )
{
int16_t *pi1;
int16_t *pi2;
pi1 = rule_1806a( &pi2 );
*pi1 = 1; /* */ /* Undefined behaviour */
*pi2 = 2; /* */ /* Undefined behaviour */
return 1;
}
static int16_t * rule_1806a( int16_t **ppi )
{
static int16_t * pc1806;
int16_t *p;
int16_t cx = 0;
{
int16_t i = 1;
p = &i; /* 3217 */
}
pc1806 = &cx; /* 3230 */
*ppi = &cx; /* 3225 */
return &cx; /* 4140 */
}
QAC messages that encompass this guideline:
| 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. |
|
||
(c) The Motor Industry Research Association, 2012
|
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |