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 |
式の値が、以下の表に記載されている実質的な型に不適切にキャストされています。
| 式の実質的な型 | 不適切なキャストとなる実質的な型 |
|---|---|
| essentially Boolean | essentially character, essentially enum, essentially signed, essentially unsigned, essentially real floating, essentially complex floating |
| essentially character | essentially Boolean, essentially enum, essentially real floating, essentially complex floating |
| essentially enum | essentially Boolean, essentially enum (except casts to exactly the same enum, which would be redundant) |
| essentially signed | essentially
Boolean, essentially enum Exception: an integer constant expression with value 0 or 1 can be cast to an essentially Boolean type. |
| essentially unsigned | essentially
Boolean, essentially enum Exception: an integer constant expression with value 0 or 1 can be cast to an essentially Boolean type. |
| essentially real floating | essentially Boolean, essentially character, essentially enum |
| essentially complex floating | essentially Boolean, essentially character, essentially enum |
このワーニングクラスは、クリティカルシステム向けのC言語ガイドラインMISRA C:2012の実質的な型に記載されている概念に基づいています。
| クラス名 | Inappropriate Cast Type | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | 不適切な型へのキャスト | |||||||||||||||
| クラス分類 | スタイル (style) | |||||||||||||||
| ニーモニック | LANG.TYPE.ICT | |||||||||||||||
| カテゴリー |
|
|||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
|||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっており、プロジェクトには非正規の C向けAST
が必要になります。有効にするにはプロジェクト設定ファイル (configuration file) に以下の WARNING_FILTER ルールと
RETAIN_UNNORMALIZED_C_AST 設定を追加してください。
RETAIN_UNNORMALIZED_C_AST = Yes WARNING_FILTER += allow class="Inappropriate Cast Type" |
typedef enum {GO, PROCEED_WITH_CAUTION, STOP} action;
typedef enum {GREEN, ORANGE, RED} light;
char LANG_TYPE_ICT(action a, char ch){
light lt;
float f;
if (ch)
lt = a; /* not an explicit cast ('Mixed enum Type' warning issued) */
else
lt = (light) a; /* 'Inappropriate Cast Type' warning issued here */
if (lt > 1)
f = (float) ch; /* 'Inappropriate Cast Type' warning issued here */
else
f = (float) (lt==0); /* 'Inappropriate Cast Type' warning issued here */
if (f > 5)
return (char) a; /* permissible cast for this warning class */
else
return 'X';
}
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.