Title
Value category of pseudo-destructor expression
Status
cd6
Section
7.6.1.5 [expr.ref]
Submitter
Andrey Erokhin

Created on 2022-02-17.00:00:00 last changed 20 months ago

Messages

Date: 2022-04-08.20:34:44

Proposed resolution (approved by CWG 2022-04-08):

Change 7.6.1.5 [expr.ref] paragraph 3 as follows:

If the object expression is of scalar type, E2 shall name the pseudo-destructor of that same type (ignoring cv-qualifications) and E1.E2 is an lvalue a prvalue of type “function of () returning void”.
Date: 2022-07-15.00:00:00

[Accepted at the July, 2022 meeting.]

Subclause 7.6.1.5 [expr.ref] paragraph 3 defines the value category of a pseudo-destructor class member access expression to be an lvalue:

Abbreviating postfix-expression.id-expression as E1.E2, E1 is called the object expression. If the object expression is of scalar type, E2 shall name the pseudo-destructor of that same type (ignoring cv-qualifications) and E1.E2 is an lvalue of type “function of () returning void”.
This is inconsistent with the analogous situation naming the destructor of a class. In that case, the class member access expression is a prvalue, not an lvalue, as specified in 7.6.1.5 [expr.ref] bullet 6.3 (see also issue 2458):
  • If E2 is an overload set, function overload resolution (12.2 [over.match]) is used to select the function to which E2 refers. The type of E1.E2 is the type of E2 and E1.E2 refers to the function referred to by E2.
    • If E2 refers to a static member function, E1.E2 is an lvalue.
    • Otherwise (when E2 refers to a non-static member function), E1.E2 is a prvalue. The expression can be used only as the left-hand operand of a member function call (11.4.2 [class.mfct]).
It also contradicts 7.2.1 [basic.lval] bullet 1.1:
  • A glvalue is an expression whose evaluation determines the identity of an object or function.
A pseudo-destructor does not have an identity.
History
Date User Action Args
2022-08-19 07:54:33adminsetstatus: ready -> cd6
2022-04-08 20:34:44adminsetstatus: open -> ready
2022-02-18 07:47:23adminsetmessages: + msg6735
2022-02-17 00:00:00admincreate