Title
Misleading parenthetical comment for explicit destructor call
Status
cd3
Section
11.4.7 [class.dtor]
Submitter
Mike Miller

Created on 2013-01-13.00:00:00 last changed 131 months ago

Messages

Date: 2013-04-15.00:00:00

[Moved to DR at the April, 2013 meeting.]

Date: 2013-02-15.00:00:00

Proposed resolution (February, 2013):

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

In an explicit destructor call, the destructor name appears as a ~ followed by a type-name or decltype-specifier that denotes the destructor's class type. The invocation of a destructor is subject to the usual rules for member functions (11.4.2 [class.mfct]),; that is, if the object is not of the destructor's class type and not of a class derived from the destructor's class type (including when the destructor is invoked via a null pointer value), the program has undefined behavior (except that invoking delete on a null pointer has no effect). [Note: invoking delete on a null pointer does not call the destructor; see 7.6.2.9 [expr.delete]. —end note] [Example:...
Date: 2013-01-13.00:00:00

According to 11.4.7 [class.dtor] paragraph 13,

The invocation of a destructor is subject to the usual rules for member functions (11.4.2 [class.mfct]), that is, if the object is not of the destructor's class type and not of a class derived from the destructor's class type, the program has undefined behavior (except that invoking delete on a null pointer has no effect).

While true, the final parenthetical comment concerns a delete-expression, not an explicit destructor call. Its presence here could mislead a careless reader to think that invoking a destructor with a null pointer is harmless. It should be deleted.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: + msg4415
2013-05-03 00:00:00adminsetstatus: tentatively ready -> dr
2013-03-18 00:00:00adminsetmessages: + msg4248
2013-03-18 00:00:00adminsetstatus: drafting -> tentatively ready
2013-01-13 00:00:00admincreate