Examples of errors detected by the V690 diagnostic.


V690. The class implements a copy constructor/operator=, but lacks the operator=/copy constructor.


Bitcoin

V690 The 'CKey' class implements a copy constructor, but lacks the the '=' operator. It is dangerous to use such a class. key.h 175


class CKey {
  ....
  // Copy constructor. This is necessary because of memlocking.
  CKey(const CKey &secret) : fValid(secret.fValid),
                             fCompressed(secret.fCompressed)
  {
    LockObject(vch);
    memcpy(vch, secret.vch, sizeof(vch));
  }
  ....
};

Similar errors can be found in some other places:

  • V690 The 'Semantic_actions' class implements the '=' operator, but lacks a copy constructor. It is dangerous to use such a class. json_spirit_reader_template.h 196
  • V690 The 'CFeeRate' class implements a copy constructor, but lacks the the '=' operator. It is dangerous to use such a class. core.h 118
  • V690 The 'CTransaction' class implements the '=' operator, but lacks a copy constructor. It is dangerous to use such a class. core.h 212
  • And 3 additional diagnostic messages.

Casablanca

V690 The '=' operator is declared as private in the '_acquire_protector' class, but the default copy constructor will still be generated by compiler. It is dangerous to use such a class. cpprestsdk140.uwp.staticlib fileio_winrt.cpp 825


struct _acquire_protector
{
  _acquire_protector(....);
  ~_acquire_protector();
  size_t   m_size;
private:
  _acquire_protector& operator=(const _acquire_protector&);
  uint8_t* m_ptr;
  concurrency::streams::streambuf<uint8_t>& m_buffer;
};

OpenJDK

V690 Copy constructor is declared as private in the 'ProductionState' class, but the default '=' operator will still be generated by compiler. It is dangerous to use such a class. dfa.cpp 76


class ProductionState {
  ....
private:
    // Disable public use of constructor, copy-ctor,  ...
  ProductionState( )                         :
  _production(cmpstr, hashstr, Form::arena)
  {  assert( false, "NotImplemented");  };
  ProductionState( const ProductionState & ) :
  _production(cmpstr, hashstr, Form::arena)
  {  assert( false, "NotImplemented");  }; // Deep-copy
};

Similar errors can be found in some other places:

  • V690 The 'MemRegion' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class. memRegion.hpp 43
  • V690 Copy constructor is declared as private in the 'Label' class, but the default '=' operator will still be generated by compiler. It is dangerous to use such a class. assembler.hpp 73

Tizen

V690 The 'SQLQueryPrivate' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class. SQLDatabaseImpl.h 26


class SQLQueryPrivate
{
public:
  std::weak_ptr<SQLDatabase> _db_ref;
  sqlite3 * _db;
  sqlite3_stmt * _stmt;
  bool _hasNext;
  std::string _query;

  SQLQueryPrivate(std::shared_ptr<SQLDatabase> db_ref,
                  sqlite3 * db, sqlite3_stmt * stmt,
                  const std::string& query);
  SQLQueryPrivate(const SQLQueryPrivate& other);
  ~SQLQueryPrivate();
};

SQLQueryPrivate::SQLQueryPrivate(const SQLQueryPrivate& other) :
    _db_ref(other._db_ref),
    _db(other._db),
    _stmt(other._stmt),
    _hasNext(other._hasNext),
    _query(other._query)
{
  const_cast<SQLQueryPrivate &>(other)._stmt = NULL;
}

Similar errors can be found in some other places:

  • V690 The 'BrowserImage' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class. BrowserImage.h 33
  • V690 The 'DownloadRequest' class implements a copy constructor, but lacks the '=' operator. It is dangerous to use such a class. download-manager-downloadRequest.h 30
  • V690 The 'CAudioError' class implements the '=' operator, but lacks a copy constructor. It is dangerous to use such a class. CAudioError.h 30
  • And 3 additional diagnostic messages.


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;
On our website we use a cookie to collect information of a technical nature.
If you do not agree, please leave the site. Learn More →
Do not show again