Main Content

Object Oriented Defects

Defects related to C++ object-oriented programming such as class design issues or issues in the inheritance hierarchy

These defects are related to the object-oriented aspect of C++ programming. The defects highlight class design issues or issues in the inheritance hierarchy. The defects include:

  • Data member not initialized or incorrectly initialized in constructor

  • Incorrect overriding of base class methods

  • Breaking of data encapsulation

Polyspace Results

*this not returned in copy assignment operatoroperator= method does not return a pointer to the current object
Base class assignment operator not calledCopy assignment operator does not call copy assignment operators of base subobjects
Base class destructor not virtualClass cannot behave polymorphically for deletion of derived class objects
Bytewise operations on nontrivial class objectValue representations may be improperly initialized or compared
Conversion or deletion of incomplete class pointerYou delete or cast to a pointer to an incomplete class
Copy constructor or assignment operator modifying source operandCopy operation modifies data member of source object
Copy constructor not called in initialization listCopy constructor does not call copy constructors of some members or base classes
Incompatible types prevent overridingDerived class method hides a virtual base class method instead of overriding it
Lambda used as typeid operandtypeid is used on lambda expression
Member not initialized in constructorConstructor does not initialize some members of a class
Missing explicit keywordConstructor or user-defined conversion operator missing the explicit specifier
Missing virtual inheritanceA base class is inherited virtually and nonvirtually in the same hierarchy
Object slicingDerived class object passed by value to function with base class parameter
Operator new not overloaded for possibly overaligned classAllocated storage might be smaller than object alignment requirement
Partial override of overloaded virtual functionsClass overrides fraction of inherited virtual functions with a given name
Return of non const handle to encapsulated data memberMethod returns pointer or reference to internal member of object
Self assignment not tested in operatorCopy assignment operator does not test for self-assignment

Topics

  • Bug Finder Defect Groups

    The Bug Finder defect checkers are classified into groups such as data flow, concurrency, numerical, and so on.