MISRA C++:2008 Rule 5-2-6
A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function type
Description
Rule Definition
A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function type.
Rationale
Because calling a function through a pointer with incompatible type results in undefined behavior, the rule forbids these cast operations:
Casting from a function pointer to any other type.
Casting from a function pointer to another function pointer, if the function pointers have different arguments and return types.
Polyspace Implementation
Polyspace® raises a violation of this rule if the source type of a cast operation is a pointer to a function.
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: Required |
Version History
Introduced in R2013b