[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 behavior.

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 */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents