Skip to content

Commit e90403b

Browse files
C++: Make constructor-used-as-copy-constructor warning/low
This query is supposed to look for constructors that unintentionally qualify as copy constructors due to default arguments. There are quite a few real-world projects that define such constructors intentionally. I've reduced the severity to "warning" and the precision to "low" due to the high false positive rate.
1 parent a782585 commit e90403b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

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)