Hello Mr. Jonathan Wakely Thank you so much for your help. As per your explanation, I tried to understand. Whether, in all cases, if I use a base class to be inherited, does the destructor always generate two variants (D0 and D2)? But when I change the code as below: virtual ~Base(){ cout << "Base Destructor called\n"; } to ~Base(){ cout << "Base Destructor called\n"; } the D0 destructor variant doesn't generate. Could you please explain more? Thank you! Best regards ________________________________ From: Jonathan Wakely Sent: Friday, March 3, 2023 3:08 PM To: Nguyen Duc Sy Cc: gcc-help Subject: Re: [NEED HELP][GCOV] uncoverage virtual destructor On Fri, 3 Mar 2023, 01:48 Nguyen Duc Sy, > 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.