Skip to content

Commit fff6c38

Browse files
authored
Merge pull request #1381 from dave-bartolomeo/dave/CopyCtor
C++: Make `constructor-used-as-copy-constructor` warning/low
2 parents 3097037 + f4d41a1 commit fff6c38

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

change-notes/1.21/analysis-cpp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
| Wrong type of arguments to formatting function (`cpp/wrong-type-format-argument`) | Fewer false positive results | Non-standard uses of %L are now understood. |
3131
| `()`-declared function called with too many arguments (`cpp/futile-params`) | Improved coverage | Query has been generalized to find all cases where the number of arguments exceedes the number of parameters of the function, provided the function is also properly declared/defined elsewhere. |
3232
| Use of potentially dangerous function (`cpp/potentially-dangerous-function`) | Fewer results | Results relating to the standard library `gets` function have been moved into a new query (`dangerous-function-overflow`). |
33+
| Constructor with default arguments will be used as a copy constructor (`cpp/constructor-used-as-copy-constructor`) | Lowered severity and precision | The severity and precision of this query have been reduced to "warning" and "low", respectively, due to this coding pattern being used intentionally and safely in a number of real-world projects. |
3334

3435
## Changes to QL libraries
3536
- The predicate `Declaration.hasGlobalName` now only holds for declarations that are not nested in a class. For example, it no longer holds for a member function `MyClass::myFunction` or a constructor `MyClass::MyClass`, whereas previously it would classify those two declarations as global names.

cpp/ql/src/jsf/4.10 Classes/AV Rule 77.1.qhelp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ when their default arguments are taken into account. An example would be a const
1111
of the form <code>X(const X&amp; rhs, int i = 0)</code>. A compiler will use such a constructor as a copy
1212
constructor in preference to the default member-wise copy constructor that it would otherwise generate.
1313
Since this is usually not what was intended, constructors of the form often do not provide the right
14-
semantics for copying objects of the class, making them potentially dangerous. Even when this sort of
15-
thing has been done intentionally, it is confusing and in bad taste, and should be avoided.
14+
semantics for copying objects of the class, making them potentially dangerous.
1615
</p>
1716

1817
</overview>

cpp/ql/src/jsf/4.10 Classes/AV Rule 77.1.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @name Constructor with default arguments will be used as a copy constructor
33
* @description Constructors with default arguments should not be signature-compatible with a copy constructor when their default arguments are taken into account.
44
* @kind problem
5-
* @problem.severity error
6-
* @precision high
5+
* @problem.severity warning
6+
* @precision low
77
* @id cpp/constructor-used-as-copy-constructor
88
* @tags reliability
99
* readability

0 commit comments

Comments
 (0)