![]() |
![]() |
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:2012 Rules applicable to message 0305:
| Rule-11.1 (Required) | Conversions shall not be performed between a pointer to a function and any other 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 |