A cast shall not be performed between a pointer to object type and a pointer to a different object type
A cast shall not be performed between a pointer to object type and a pointer to a different object type.
If a pointer to an object is cast into a pointer to a different object, the resulting pointer can be incorrectly aligned. The incorrect alignment causes undefined behavior.
Even if the conversion produces a pointer that is correctly aligned, the behavior can be undefined if the pointer is used to access an object.
Exception: You can convert a pointer to object type into a pointer to one of the following types:
char
signed char
unsigned char
If you expect a rule violation but do not see it, refer to the documentation of Polyspace® Code Prover™ or Polyspace Code Prover Server™.
| Group: Pointer Type Conversions |
| Category: Required |
| AGC Category: Required |