MISRAC++2008-5-2-9
In this section:
Synopsis
(Advisory) A cast should not convert a pointer type to an integral type.
Enabled by default
No
Severity/Certainty
Low/Medium

Full description
A cast from a pointer type to an integral type was found. This check is identical to MISRAC2004-11.3, MISRAC2012-Rule-11.4, MISRAC++2023-8.2.7.
Coding standards
- MISRA C:2004 11.3
(Advisory) A cast should not be performed between a pointer type and an integral type.
- MISRA C:2012 Rule-11.4
(Advisory) A conversion should not be performed between a pointer to object and an integer type
- MISRA C++ 2023 8.2.7
(Advisory) A cast should not convert a pointer type to an integral type
Code examples
The following code example fails the check and will give a warning:
void example(void) {
int *p;
int x;
x = (int)p;
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
int *p;
int *x;
x = p;
}