JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
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
MisraC2025 MisraC2025:11.1 Conversions shall not be performed between a pointer to a function and any other type
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
                          * ('Bad Initializer Type' warning also issued)
                          */

Relevant Configuration File Parameters

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

 

To report problems with this documentation, please visit https://support.codesecure.com/.