![]() |
![]() |
0305 | ![]() |
||||
![]() | |||||||
| Pointers | REFERENCE - ISO:C90-6.3.4 Cast Operators - Semantics | ||||||
A cast is being performed between an integral type and a pointer to function type, or vice versa. Any cast which maps integer values to pointer values is by nature implementation-defined. When casting from a pointer type to an integer type, the size of integer which is required will also be implementation defined. However this type of operation is not uncommon in embedded software applications. For example:
/*PRQA S 2017,2211,3120,3199,3203,3408,3447,3672 ++*/
extern int (* pf)(int x);
extern void foo(void)
{
unsigned short mus;
unsigned long mul;
pf = (int (*)(int x))0xC000U; /* Message 0305 */
mul = (unsigned long)pf; /* Message 0305 */
mus = (unsigned short)pf; /* Message 0305 and 0309 */
}
MISRA-C:2004 Rules applicable to message 0305:
| Rule 3.1 (Required) | All usage of implementation-defined behaviour shall be documented. |
| Rule 11.3 (Advisory) | A cast should not be performed between a pointer type and an integral type. |
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 |