mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
CPP: Add test case.
This commit is contained in:
@@ -201,6 +201,18 @@ struct TemplatedAssignmentBad {
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class Obj3 {
|
||||
public:
|
||||
Obj3<T> &subFunc(const Obj3<T> &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Obj3<T> &operator=(const Obj3<T> &other) {
|
||||
return subFunc(other); // GOOD (returns *this) [FALSE POSITIVE]
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
Container c;
|
||||
c = c;
|
||||
@@ -211,5 +223,7 @@ int main() {
|
||||
taGood = 3;
|
||||
TemplatedAssignmentBad taBad;
|
||||
taBad = 4;
|
||||
Obj3<int> obj3_a, obj3_b;
|
||||
obj3_a = obj3_b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
| AV Rule 82.cpp:63:29:63:29 | operator= | Assignment operator in class TemplateReturnAssignment<int> does not return a reference to *this. |
|
||||
| AV Rule 82.cpp:63:29:63:37 | operator= | Assignment operator in class TemplateReturnAssignment<T> does not return a reference to *this. |
|
||||
| AV Rule 82.cpp:199:52:199:52 | operator= | Assignment operator in class TemplatedAssignmentBad should have return type TemplatedAssignmentBad&. Otherwise a copy is created at each call. |
|
||||
| AV Rule 82.cpp:211:12:211:20 | operator= | Assignment operator in class Obj3<T> does not return a reference to *this. |
|
||||
|
||||
Reference in New Issue
Block a user