Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
Examples of errors detected by the...

Examples of errors detected by the V1002 diagnostic

V1002. Class that contains pointers, constructor and destructor is copied by the automatically generated operator= or copy constructor.


Dagor Engine

V1002 Instantiation of Vector < MountVromfsRec, MemPtrAllocator, bool, uint32_t >: The 'MountVromfsRec' class, containing pointers, constructor and destructor, is copied by the automatically generated copy constructor. DagorEngine/prog/1stPartyLibs/dag/dag_vector.h 567


void DoInsertValues(const_iterator position,
                    size_type n,
                    const value_type& value) {
  const value_type temp  = value;
}

template <typename T, ....>
class Vector
{
  ....
  typedef T value_type;
  ....
}

struct MountVromfsRec
{
  VirtualRomFsPack *vd;
  SimpleString fn;
  SimpleString mountPath;

  MountVromfsRec() : vd(NULL) {}
  ~MountVromfsRec()
  {
    remove_vromfs(vd);
    close_vromfs_pack(vd, inimem);
    vd = NULL;
  }
};

static Tab<MountVromfsRec> mnt_vromfs(inimem);

template <typename T>
using Tab = dag::Vector<T, dag::MemPtrAllocator, false, uint32_t>;

YTsaurus

V1002 The 'TTimerGuard' class, containing pointers, constructor and destructor, is copied by the automatically generated copy constructor. schemaless_chunk_reader.cpp:731


template <class TTimer>
class TTimerGuard
{
public:
  explicit TTimerGuard(TTimer* timer)
  {
    Timer_->Start();
  }

  ~TTimerGuard()
  {
    Timer_->Stop();
  }

private:
  TTimer* const Timer_;
};

The 'TTimerGuard' class template is a RAII wrapper over 'TTimer' and has a trivial copy constructor generated by the compiler. Wrappers of this kind are usually made to disallow copy semantics but allow move semantics.


Ardour

V1002 The 'XMLProcessorSelection' class, containing pointers, constructor and destructor, is copied by the automatically generated operator=. processor_selection.cc 25


XMLProcessorSelection processors;

ProcessorSelection&
ProcessorSelection::operator= (ProcessorSelection const & other)
{
  if (this != &other) {
    processors = other.processors; // <=
  }

  return *this;
}

class XMLProcessorSelection {
  public:
 XMLProcessorSelection() : node (0) {}
 ~XMLProcessorSelection() { if (node) { delete node; } }

 void set (XMLNode* n) {
  if (node) {
   delete node;
  }
  node = n;
 }

 void add (XMLNode* newchild) {
  if (!node) {
   node = new XMLNode ("add");
  }
  node->add_child_nocopy (*newchild);
 }

 void clear () {
  if (node) {
   delete node;
   node = 0;
  }
 }

 bool empty () const { return node == 0 || ....empty(); }

 const XMLNode& get_node() const { return *node; }

  private:
 XMLNode* node; // <=
};

Instead of assignment, set() or add() functions had to be used.