On Fri, 3 Mar 2023, 01:48 Nguyen Duc Sy, <sy.nguyen-duc@xxxxxxxxxxxxxx> wrote: > Hello Mr. Jonathan Wakely > > Basically, my program only creates a Base class to be inherited, and only > uses the Derived1 class in the main program. > And the coverage checks are telling you there is unused code, which is correct. You have defined a type that can be used on its own or as a base class, but then you don't use it on its own. The code for using it on its own is never executed. Make it an abstract class (with a pure virtual function) if it should only be usable as a base class. What is the purpose of the D0 destructor variant that G++ generates? > It destroys the object and then calls operator delete(this, sizeof(Base)). That is only used when Base is a complete object, not a base class. To destroy a base class the D2 variant is used. It is clear that the content of the ~Base() function, which is > cout << "Base Destructor called\n"; > , is still executed. > There are two versions of the destructor code, and the message is only printed once, so obviously only one of them executes. Either test destroying a non-base-class object of type Base to use the D0 destructor, or tell the compiler that Base can only be a base class by making it abstract, or accept that the D0 destructor will not have coverage data.