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.CAST.PC.DATA2FN : 関数ポインタへの型変換

要旨

関数ポインタ以外の値が関数ポインタ型にキャストもしくは暗黙型変換されています。

プロパティ

クラス名 Conversion to Function Pointer
日本語クラス名 関数ポインタへの型変換
クラス分類 セキュリティ (security)
ニーモニック LANG.CAST.PC.DATA2FN
カテゴリー
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
AUTOSARC++14 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:8-4-4 A function identifier shall either be used to call the function or it shall be preceded by &.
MisraC++2023 MisraC++2023:7.11.3 A conversion from function type to pointer-to-function type shall only occur in appropriate contexts
  MisraC++2023:8.2.4 Casts shall not be performed between a pointer to a function and any other type
CWE CWE:704 Incorrect Type Conversion or Cast
TS17961 TS17961:5.1-ptrcomp Accessing an object through a pointer to an incompatible type
  TS17961:5.6-argcomp Calling functions with incorrect arguments
JSF++ JSF++:182 Type casting from any type to or from pointers shall not be used.
  JSF++:183 Every possible measure should be taken to avoid type casting.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Conversion to Function Pointer"

typedef int (*TakesIntRetsInt)(int) ;

int PC_DATA2FN( int x){
    TakesIntRetsInt f = (TakesIntRetsInt) x; /* 'Conversion to Function Pointer' warning issued here */
    TakesIntRetsInt g =  x;                  /* 'Conversion to Function Pointer' warning issued here
                                              * ('Bad Initializer Type' warning also issued)
                                              */
    return (f(5) + g(5));
}

See also

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。

 

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