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.0p0 Hot Tips | CONFIDENTIAL | CodeSecure Inc |
対象となる変数は変更されておらず、けれども const 宣言若しくは(C++のみ) constexpr宣言もされていません。
Pointed-to Type Could Be constも併せて確認して下さい。
| クラス名 | Variable Could Be const | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | const宣言もしくはconstexpr宣言可能な変数 | ||||||||||||
| クラス分類 | スタイル (style) | ||||||||||||
| ニーモニック | LANG.TYPE.VCBC | ||||||||||||
| カテゴリー |
|
||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Variable Could Be const" |
int use_params(int * p1, // ok: p1 is modified int * p2, // 'Variable Could Be const' warning issued here int * const p3){ // ok: unmodified parameter marked const if (!p1 || !p2 || !p3) {return -1;} p1 = p2; // p1 is modified here *p2 = 2; // *p2 is modified here, but p2 is not modified return *p1 + *p2 + *p3; } constexpr int five(void) {return 5;} int use_locals(const int k){ // ok: unmodified parameter marked const int a = five(); // 'Variable Could Be const' warning issued here const int b = five(); // ok: unmodified local marked const constexpr int c = five(); // ok: unmodified local marked constexpr int d = five(); // ok: local modified on some paths if (k){ d++; } return a + b + c + d; }
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。