mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
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.
This commit is contained in:
@@ -11,8 +11,7 @@ when their default arguments are taken into account. An example would be a const
|
||||
of the form <code>X(const X& rhs, int i = 0)</code>. A compiler will use such a constructor as a copy
|
||||
constructor in preference to the default member-wise copy constructor that it would otherwise generate.
|
||||
Since this is usually not what was intended, constructors of the form often do not provide the right
|
||||
semantics for copying objects of the class, making them potentially dangerous. Even when this sort of
|
||||
thing has been done intentionally, it is confusing and in bad taste, and should be avoided.
|
||||
semantics for copying objects of the class, making them potentially dangerous.
|
||||
</p>
|
||||
|
||||
</overview>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* @name Constructor with default arguments will be used as a copy constructor
|
||||
* @description Constructors with default arguments should not be signature-compatible with a copy constructor when their default arguments are taken into account.
|
||||
* @kind problem
|
||||
* @problem.severity error
|
||||
* @precision high
|
||||
* @problem.severity warning
|
||||
* @precision low
|
||||
* @id cpp/constructor-used-as-copy-constructor
|
||||
* @tags reliability
|
||||
* readability
|
||||
|
||||
Reference in New Issue
Block a user