Title
When can/must a defaulted virtual destructor be defined?
Status
cd4
Section
11.4.7 [class.dtor]
Submitter
Richard Smith

Created on 2015-01-12.00:00:00 last changed 94 months ago

Messages

Date: 2015-09-15.00:00:00

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.
Date: 2016-02-15.00:00:00

[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.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: tentatively ready -> cd4
2015-11-10 00:00:00adminsetmessages: + msg5605
2015-11-10 00:00:00adminsetstatus: drafting -> tentatively ready
2015-01-12 00:00:00admincreate