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 |
A value is cast or coerced to type bool.
Warnings of this class are not issued in the following cases.
| クラス名 | Conversion to Type bool | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | Conversion to Type bool | |||||||||||||||||||||
| クラス分類 | 信頼性 (reliability) | |||||||||||||||||||||
| ニーモニック | LANG.CAST.BOOL | |||||||||||||||||||||
| カテゴリー |
|
|||||||||||||||||||||
| 対応言語 | C++ のみ利用可能です。 C は利用できません。 |
|||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Conversion to Type bool" |
class Expl {
int m;
public:
Expl( int x ) : m(x) {}
explicit operator bool() const { return m > 0; }
};
class Impl {
int m;
public:
Impl( int x ) : m(x) {}
operator bool() const { return m > 0; }
};
void conv2bool( int x, int *p ) {
Expl e(x);
Impl i(x);
while (x) break; // 'Conversion to Type bool' warning issued here
while (!0) break; // 'Conversion to Type bool' warning issued here
while (p) break; // ok: converting a value of pointer type
while (static_cast<bool>(i)) // 'Conversion to Type bool' warning issued here
// (class Impl has operator bool() but it is not marked explicit)
break;
while (static_cast<bool>(e)) // ok: class Expl has explicit operator bool()
break;
}
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.