C and C++


LANG.STRUCT.FUNCPTR.CONVERT : Function Pointer Conversion

Summary

A function pointer was cast to a different type.

Properties

Class Name Function Pointer Conversion
Significance style
Mnemonic LANG.STRUCT.FUNCPTR.CONVERT
Categories
MisraC2023 MisraC2023:11.1 Conversions shall not be performed between a pointer to a function and any other type
Misra2012 Misra2012:11.1 Conversions shall not be performed between a pointer to a function and any other type
Misra2004 Misra2004:11.1 Conversions shall not be performed between a pointer to a function and any type other than an integral type
  Misra2004:11.2 Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to object type or a pointer to void
  Misra2004:11.3 A cast should not be performed between a pointer type and an integral type
AUTOSARC++14 AUTOSARC++14:M5-2-6 A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function type.
  AUTOSARC++14:M8-4-4 A function identifier shall either be used to call the function or it shall be preceded by &.
MisraC++2008 MisraC++2008:5-2-6 A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function type.
  MisraC++2008:8-4-4 A function identifier shall either be used to call the function or it shall be preceded by &.
CWE CWE:710 Improper Adherence to Coding Standards
JPL JPL:30 Do not cast function pointers into other types.
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default. To enable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Function Pointer Conversion"

Example

unsigned char ucatch(int);

char (*f)(int) = ucatch; /* 'Function Pointer Conversion' warning issued here*/

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.