Unreliable cast of function pointer
Function pointer cast to another function pointer with different argument or return type
Description
This defect occurs when a function pointer is cast to another function pointer that has different argument or return type.
Risk
If you cast a function pointer to another function pointer with different argument or return type and then use the latter function pointer to call a function, the behavior is undefined.
Fix
Avoid a cast between two function pointers with mismatch in argument or return types.
See examples of fixes below.
If you do not want to fix the issue, add comments to your result or code to avoid another review. See:
Address Results in Polyspace User Interface Through Bug Fixes or Justifications if you review results in the Polyspace user interface.
Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access) if you review results in a web browser.
Annotate Code and Hide Known or Acceptable Results if you review results in an IDE.
Examples
Result Information
Group: Static memory |
Language: C | C++ |
Default: On |
Command-Line Syntax: FUNC_CAST |
Impact: Medium |
Version History
Introduced in R2013b
See Also
Find defects (-checkers)
| Unreliable cast of pointer
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)