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.
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.
YTsaurus
V1002 The 'TTimerGuard' class, containing pointers, constructor and destructor, is copied by the automatically generated copy constructor. schemaless_chunk_reader.cpp:731
IUnversionedRowBatchPtr
THorizontalSchemalessRangeChunkReader::Read(
const TRowBatchReadOptions& options)
{
TCurrentTraceContextGuard traceGuard(TraceContext_);
auto readGuard = AcquireReadGuard(); // <=
....
}
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>;