![]() |
![]() |
0308 | ![]() |
||||
![]() | |||||||
| Pointers | REFERENCE - ISO:C90-6.3.4 Cast Operators - Semantics | ||||||
An expression of pointer type is being cast to a different pointer type and at least one of the types is incomplete. Casts involving pointers to incomplete type should be conducted with particular caution in order to avoid the possibility of casting to a type with stricter alignment requirements. Be aware that the alignment requirements of a struct are dependent on the type of the first member within the struct. Message 0308 is generated when a cast is identified which performs one of the following conversions:
/*PRQA S 2017,3198,3199,3203,3227,3313,3408,3447 ++*/
extern struct ST1 * pst1; /* Pointer to incomplete type */
extern struct ST2 * pst2; /* Pointer to incomplete type */
extern unsigned long * pul; /* Pointer to complete type */
extern void foo(void)
{
pst1 = (struct ST1 *)pul; /* a) Message 0308 and 0310 */
pul = (unsigned long *)pst1; /* b) Message 0308 and 0310 */
pst2 = (struct ST2 *)pst1; /* c) Message 0308 and 0310 */
}
MISRA-C:2004 Rules applicable to message 0308:
| Rule 3.1 (Required) | All usage of implementation-defined behaviour shall be documented. |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |