[previous] 0310 [next] Casting to different object pointer type.
Pointers REFERENCE - ISO:C90-6.3.4 Cast Operators - Semantics

An expression of 'pointer-to-object' type is being cast to a different 'pointer-to-object' type.

Casts involving pointers should always be conducted with caution because the size and alignment of types is implementation-defined. Casting to a type with stricter alignment requirements will result in undefined behaviour.

For example:


/*PRQA S 2017,2211,3199,3203,3227,3408,3447,3625,3631 ++*/

extern char *pca;
extern char *pcb;
extern int  *pi;

extern void foo(void)
{
   pca = (char *)pi;             /* Message 0310        */
   pi  = (int *)pcb;             /* Message 0310 & 3305 */
}


MISRA C:2012 Rules applicable to message 0310:

Rule-11.3  (Required) A cast shall not be performed between a pointer to object type and a pointer to a different object type


See also:

QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents