MISRA C:2012 Rule 11.3
A conversion shall not be performed between a pointer to object type and a pointer to a different object type
Description
Rule Definition
A conversion shall not be performed between a pointer to object type and a pointer to a different object type.
Rationale
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.
As an exception MISRA C:2012 standard permits converting a pointer to a
non-atomic
qualified object type into a pointer to one of the following types:
char
signed char
unsigned char
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Pointer Type Conversions |
Category: Required |
AGC Category: Required |