![]() |
|
MISRA C:2012 Rule-11.3: (Required) |
|
||||
![]() | |||||||
Amplification:
This rule applies to the unqualified types that are pointed to by the pointers.
Exception:
It is permitted to convert a pointer to object type into a pointer to one of the object types char, signed char or unsigned char. The Standard guarantees that pointers to these types can be used to access the individual bytes of an object.
Example Code:
#pragma PRQA_MESSAGES_OFF 2982,3408,3447
#include "misra.h"
#include "m3cmex.h"
extern char * ppc;
extern int8_t * psc;
extern uint8_t * puc;
extern uint16_t * pui;
extern uint32_t * pul;
extern float32_t * pft;
extern int16_t rule_1103( void )
{
psc = ( int8_t *)ppc; /* 0310 */ /* Compliant */
puc = (uint8_t *)ppc; /* 0310 */ /* Compliant */
pui = (uint16_t *)ppc; /* 0310 3305 */
pul = (uint32_t *)ppc; /* 0310 3305 */
pft = (float32_t *)ppc; /* 0310 3305 */
ppc = ( char *)psc; /* 0310 */ /* Compliant */
puc = (uint8_t *)psc; /* 0310 */ /* Compliant */
pui = (uint16_t *)psc; /* 0310 3305 */
pul = (uint32_t *)psc; /* 0310 3305 */
pft = (float32_t *)psc; /* 0310 3305 */
ppc = ( char *)puc; /* 0310 */ /* Compliant */
psc = ( int8_t *)puc; /* 0310 */ /* Compliant */
pui = (uint16_t *)puc; /* 0310 3305 */
pul = (uint32_t *)puc; /* 0310 3305 */
pft = (float32_t *)puc; /* 0310 3305 */
ppc = ( char *)pui; /* 0310 */ /* Compliant */
psc = ( int8_t *)pui; /* 0310 */ /* Compliant */
puc = (uint8_t *)pui; /* 0310 */ /* Compliant */
pul = (uint32_t *)pui; /* 0310 3305 */
pft = (float32_t *)pui; /* 0310 3305 */
ppc = ( char *)pul; /* 0310 */ /* Compliant */
psc = ( int8_t *)pul; /* 0310 */ /* Compliant */
puc = (uint8_t *)pul; /* 0310 */ /* Compliant */
pui = (uint16_t *)pul; /* 0310 */
pft = (float32_t *)pul; /* 0310 */
ppc = ( char *)pft; /* 0310 */ /* Compliant */
psc = ( int8_t *)pft; /* 0310 */ /* Compliant */
puc = (uint8_t *)pft; /* 0310 */ /* Compliant */
pui = (uint16_t *)pft; /* 0310 */
pul = (uint32_t *)pft; /* 0310 */
return 0;
}
QAC messages that encompass this guideline:
| 0310 | Casting to different object pointer type. |
| 3305 | Pointer cast to stricter alignment. |
|
||
(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 |