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

2025-04-13


3022. Redundant specification of explicit destructor calls

Section: 11.4.7  [class.dtor]     Status: open     Submitter: Timur Doumler     Date: 2025-04-13

Subclause 11.4.7 [class.dtor] paragraph 16 explains explicit destructor calls, but that is redundant with 7.5.5.2 [expr.prim.id.unqual], 7.5.5.5 [expr.prim.id.dtor], and the usual rules for function calls (7.6.1.3 [expr.call]).

Possible resolution:

  1. Change in 7.5.5.2 [expr.prim.id.unqual] paragraph 1 as follows:

    An identifier is only an id-expression if it has been suitably declared (Clause Clause 9 [dcl]) or if it appears as part of a declarator-id (9.3 [dcl.decl]). [Note 1: For operator-function-ids, see 12.4 [over.oper]; for conversion-function-ids, see 11.4.8.3 [class.conv.fct]; for literal-operator-ids, see 12.6 [over.literal]; for template-ids, see 13.3 [temp.names]. end note] A type-name or computed-type-specifier prefixed by ~ denotes the destructor of the type so named; see 7.5.5.5 [expr.prim.id.dtor]. end note]
  2. Change in 11.4.7 [class.dtor] paragraph 16 as follows:

    [ Note: In an explicit destructor call, the destructor is specified by a ~ followed by a type-name or computed-type-specifier that denotes the destructor's class type (7.5.5.2 [expr.prim.id.unqual]). The invocation of a destructor is subject to the usual rules for member functions (11.4.2 [class.mfct]) (7.6.1.3 [expr.call]); 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. [Note 7: Invoking delete on a null pointer does not call the destructor; see 7.6.2.9 [expr.delete]. end note] [Example: ... -- end example] end note]