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 |
An assignment operator (operator=) does not return a value equal to *this, and is used one or more times in the analyzed code.
| クラス名 | Inappropriate Assignment Operator Return | ||||||
|---|---|---|---|---|---|---|---|
| 日本語クラス名 | Inappropriate Assignment Operator Return | ||||||
| クラス分類 | スタイル (style) | ||||||
| ニーモニック | LANG.STRUCT.ASSIGNRET | ||||||
| カテゴリー |
|
||||||
| 対応言語 | C++ のみ利用可能です。 C は利用できません。 |
||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Inappropriate Assignment Operator Return" |
class MyClass1 {
public:
MyClass1(int x) : m_x(x) {};
MyClass1 & operator=(MyClass1 & other) {
m_x = other.m_x;
return other; // 'Inappropriate Assignment Operator Return' warning issued here
}
private:
int m_x;
};
class MyClass2 {
public:
MyClass2(int x) : m_x(x) {};
void operator=(MyClass2 & other) { // 'Inappropriate Assignment Operator Return' warning issued here
m_x = other.m_x;
}
private:
int m_x;
};
class MyClass3 {
public:
MyClass3(int x) : m_x(x) {};
MyClass3 & operator=(MyClass3 & other) {
m_x = other.m_x;
return *this; // ok: returns *this
}
private:
int m_x;
};
// Use the assignment operators so that they are instantiated.
void test( MyClass1 & p1, MyClass2 & p2, MyClass3 & p3 )
{
MyClass1 v1(0);
MyClass2 v2(0);
MyClass3 v3(0);
v1 = p1;
v2 = p2;
v3 = p3;
}
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.