This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 113d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-03-20


2068. When can/must a defaulted virtual destructor be defined?

Section: 11.4.7  [class.dtor]     Status: CD4     Submitter: Richard Smith     Date: 2015-01-12

[Adopted at the February, 2016 meeting.]

The rules in 6.3 [basic.def.odr] and 11.4.7 [class.dtor] do not specify when the destructor for B can/must be defined:

   struct A { virtual ~A(); };
   struct B : A {};
   int main() {
     A *p = new B;
     delete p;
   }

An implementation should be allowed, but not required, to implicitly define a virtual special member function at any point where it has been desclared, as well as being required to define it as described in 11.4.7 [class.dtor] paragraph 6, etc.

Proposed resolution (September, 2015):

Change 11.4.7 [class.dtor] paragraph 6 as follows:

A destructor that is defaulted and not defined as deleted is implicitly defined when it is odr-used (6.3 [basic.def.odr]) to destroy an object of its class type (6.7.5 [basic.stc]) or when it is explicitly defaulted after its first declaration.