MISRA C++:2008 Rule 5-2-9
A cast should not convert a pointer type to an integral type
Description
Rule Definition
A cast should not convert a pointer type to an integral type.
Rationale
The C++ standard specifies only the minimum size required for integral types. The implemented size of integral types and pointers depends on your hardware and development environment. In an environment where pointers have a larger size than integral types, casting a pointer type to an integral type results in an overflow. Avoid casting pointers to integral types.
Polyspace Implementation
Polyspace® flags a casting operation if it converts a pointer type variable to an integral type variable.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Expressions |
Category: Advisory |
Version History
Introduced in R2013b