JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++


PARSE.DOIC : delete of Incomplete Class

Summary

The delete operation is applied to a pointer of type T*, where T is an incomplete class type.

This warning class is derived from a C/C++ parser warning.

Properties

Class Name delete of Incomplete Class
Significance style
Mnemonic PARSE.DOIC
Categories
AUTOSARC++14 AUTOSARC++14:A5-3-3 Pointers to incomplete class types shall not be deleted.
MisraC++2023 MisraC++2023:21.6.5 A pointer to an incomplete class type shall not be deleted
CWE CWE:404 Improper Resource Shutdown or Release
CERT-CPP CERT-CPP:EXP57-CPP Do not cast or delete pointers to incomplete classes
Availability Available for C++ only (not C).
Enabling Checks for this warning class are enabled by default. However, warning instances of this class that are issued as parser errors (rather than parser warnings) will be discarded when using factory configuration settings. To prevent these instances from being discarded, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="delete of Incomplete Class"
To disable checks for this warning class, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="delete of Incomplete Class"

Example

// PARSE.DOIC.cpp

#include "PARSE.DOIC.hpp"

class A::ForwardDecCl {};                           // define A::ForwardDecCl, but later than A::~A()

class C::ForwardDecCl {};                           // define C::ForwardDecCl

C::~C() {
    delete ptrFDC;                                  // C::ForwardDecCl is a complete class at this point
}
// PARSE.DOIC.hpp

class A {
  private:
    class ForwardDecCl;
    ForwardDecCl * ptrFDC;
  public:
    ~A() {
      delete ptrFDC;   // 'delete of Incomplete Class' warning issued here
                       // - A::ForwardDecCl is an incomplete class at this point
    }
};

class B {
  private:
    class DefCl {};                                   // Define B::DefCl
    DefCl * ptrDC;
  public:
    ~B() {
      delete ptrDC;                                   // B::DefCl is a complete class at this point
  }
};

class C {
  private:
    class ForwardDecCl;
    ForwardDecCl * ptrFDC;
  public:
    ~C();                                             // C::~C() declared but not defined
};

Relevant Configuration File Parameters

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

 

To report problems with this documentation, please visit https://support.codesecure.com/.