C and C++


LANG.TYPE.UIGO : Unneeded Implicitly Generated Operations

Summary

A class has one or more implicitly generated operations that are never used.

The operations that may be implicitly generated are:

A warning of this class may indicate that code that is intended to use an implicitly generated operation is not behaving as expected.
You can prevent implicit generation for a specific operation by declaring the function private and leaving it undefined, or by explicitly deleting it with =delete.

Properties

Class Name Unneeded Implicitly Generated Operations
Significance style
Mnemonic LANG.TYPE.UIGO
Categories
CWE CWE:1076 Insufficient Adherence to Expected Conventions
JSF++ JSF++:68 Unneeded implicitly generated member functions shall be explicitly disallowed.
Availability Available for C++ only (not C).
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Unneeded Implicitly Generated Operations"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

class A { // 'Unneeded Implicitly Defined Operation' warning issued here.
          // The warning will list the following, which are implicitly defined but never used.
          // - copy assignment operator
          // - move constructor
          // - move assignment operator
          //
          // There is no implicitly defined default constructor, because it's explicitly defined.
          // The implicitly defined copy constructor is used in do_A().

  public:
    A() {};                         // Default constructor explicitly defined.
                                    // Copy constructor NOT explicitly defined.
};

void do_A(A one) {
    A two(one);                     // Implicitly defined copy constructor used here.
}

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.