MISRA C++:2008 Rule 5-2-7
An object with pointer type shall not be converted to an unrelated pointer type, either directly or indirectly
Description
Rule Definition
An object with pointer type shall not be converted to an unrelated pointer type, either directly or indirectly.
Rationale
If you convert a pointer to a pointer of unrelated type, the result of the operation is unspecified. To avoid unexpected results, do not convert a pointers to an unrelated pointer type.
Polyspace Implementation
The checker flags all pointer conversions including between a pointer to a
struct
object and a pointer to the first member of the same
struct
type.
Indirect conversions from a pointer to non-pointer type are not detected.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Check Information
Group: Expressions |
Category: Required |
Version History
Introduced in R2013b