| Document #: | P4176R1 [Latest] [Status] |
| Date: | 2026-05-12 |
| Project: | Programming Language C++ |
| Audience: |
Core Working Group |
| Reply-to: |
Vlad Serebrennikov <serebrennikov.vladislav@gmail.com> |
7.6.1 [expr.post] lists all the grammar at the top, while the rest of the subclause resorts to either quoting the grammar or describing it with words. This paper aims to improve the situation, introducing new non-terminals and putting their definitions in the respective subclauses.
R1:
R0:
No changes to behavior of programs are intended.
Change 7.6.1.1 [expr.post.general] paragraph 1 as follows:
1 Postfix expressions group left-to-right.
postfix-expression:primary-expressionpostfix-expression[expression-listopt]subscript-expressionpostfix-expression(expression-listopt)function-call-expressionsimple-type-specifier(expression-listopt)
typename-specifier(expression-listopt)
simple-type-specifier braced-init-list
typename-specifier braced-init-listtype-conversion-expressionpostfix-expression.templateopt id-expression
postfix-expression.splice-expression
postfix-expression->templateopt id-expression
postfix-expression->splice-expressionclass-member-access-expressionpostfix-expression++post-increment-expressionpostfix-expression--post-decrement-expressiondynamic_cast<type-id>(expression)dynamic-cast-expressionstatic_cast<type-id>(expression)static-cast-expressionreinterpret_cast<type-id>(expression)reinterpret-cast-expressionconst_cast<type-id>(expression)const-cast-expressiontypeid(expression)
typeid(type-id)typeid-expressionexpression-list:initializer-list
Remove 7.6.1.1 [expr.post.general] paragraph 2:
[Note: The
>token following the type-id in adynamic_cast,static_cast,reinterpret_cast, orconst_castcan be the product of replacing a>>token by two consecutive>tokens (13.3 [temp.names]). — end note ]
[ Drafting note: A similar note is added to each kind of cast. ]
Change 7.6.1.2 [expr.sub] paragraph 1 as follows:
subscript-expression:postfix-expression[expression-listopt]1
A subscript expression is a postfix expression followed by square brackets containing a possibly empty, comma-separated list of initializer-clauses thatThe expression-list, if present, constitutes the arguments to the subscript operator. The postfix-expression and the initialization of the object parameter (9.3.4.6 [dcl.fct]) of any applicable subscript operator function (12.4.5 [over.sub]) is sequenced before each expression in the expression-list and also before any default argument (9.3.4.7 [dcl.fct.default]). The initialization of a non-object parameter of a subscript operator functionS, including every associated value computation and side effect, is indeterminately sequenced with respect to that of any other non-object parameter ofS.
Change 7.6.1.3 [expr.call] paragraph 1 as follows:
function-call-expression:postfix-expression(expression-listopt)1
A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of initializer-clauses whichThe expression-list, if present, constitutes the arguments tothea function designated by the postfix-expression.[Note: If the
postfix expressionpostfix-expression is a function name, the appropriate function and the validity of the call are determined according to the rules in 12.2 [over.match]. — end note ]The
postfix expressionpostfix-expression E shall have function type or function pointer type. For a call to a non-member function or to a static member function,the postfix expressionE shall be either an lvalue that refers to a function (in which case the function-to-pointer standard conversion (7.3.4 [conv.func]) is suppressed onthe postfix expressionE), or a prvalue of function pointer type.
Change 7.6.1.3 [expr.call] paragraph 2 as follows:
2 If the selected function is non-virtual, or if
the id-expression in the class member access expressionE is a class-member-access-expression whose id-expression is a qualified-id, that function is called. Otherwise, its final overrider (11.7.3 [class.virtual]) in the dynamic type of the object expression is called; such a call is referred to as a virtual function call.[Note: [. . .] — end note ]
Change 7.6.1.4 [expr.type.conv] paragraph 1 as follows:
type-conversion-expression:simple-type-specifier(expression-listopt)
typename-specifier(expression-listopt)
simple-type-specifier braced-init-list
typename-specifier braced-init-list1
A simple-type-specifier or typename-specifier followed by a parenthesized optional expression-list or by a braced-init-list (the initializer)A type-conversion-expression constructs a value of thespecifiedtype specified by the simple-type-specifier or typename-specifier.givenThe braced-init-list or parentheses containing optional expression-list is the initializer. If the type is a placeholder for a deduced class type, it is replaced by the return type of the function selected by overload resolution for class template deduction for the remainder of this subclause. Otherwise, if the type contains a placeholder type, it is replaced by the type determined by placeholder type deduction (9.2.9.7.2 [dcl.type.auto.deduct]). LetTdenote the resulting type. Then:
- (1.1) If the initializer is a parenthesized
single expressionexpression-list with a single assignment-expression, the type conversion expression is equivalent to the corresponding cast expression (7.6.3 [expr.cast]).- (1.2) Otherwise, if
Tis cvvoid, the initializer shall be()or{}(after pack expansion, if any), and the expression is a prvalue of typevoidthat performs no initialization.- (1.3) Otherwise, if
Tis a reference type, the expression has the same effect as direct-initializing an invented variabletof typeTfrom the initializer and then usingtas the result of the expression; the result is an lvalue ifTis an lvalue reference type or an rvalue reference to function type and an xvalue otherwise.- (1.4) Otherwise, the expression is a prvalue of type
Twhose result object is direct-initialized (9.5 [dcl.init]) with the initializer.If the initializer is a parenthesized optional expression-list,
Tshall not be an array type.[Example: [. . .] — end example ]
[ Drafting note: Do we want to use “(possibly parenthesized)” here,
given “the initializer shall be
() or
{}” in 1.2? ]
Change 7.6.1.5 [expr.ref] paragraph 1 as follows:
class-member-access-expression:postfix-expression.templateopt id-expression
postfix-expression.splice-expression
postfix-expression->templateopt id-expression
postfix-expression->splice-expression1
A postfix expression followed by a dot.or an arrow->, optionally followed by the keywordtemplate, and then followed by an id-expression or a splice-expression, is a postfix expression.[Note: If the keyword
templateis used and followed by an id-expression, the unqualified name is considered to refer to a template (13.3 [temp.names]). If a simple-template-id results and is followed by a::, the id-expression is a qualified-id. — end note ]
[ Drafting note: This note is under consideration by CWG3180. ]
Change footnote 45 referenced from 7.6.1.5 [expr.ref] paragraph 3:
If the
class member access expressionclass-member-access-expression is evaluated, the subexpression evaluation happens even if the result is unnecessary to determine the value of the entire postfix expression, for example if the id-expression denotes a static member.
Change 7.6.1.6 [expr.post.incr] paragraph 1 as follows:
post-increment-expressionpostfix-expression++post-decrement-expressionpostfix-expression--1 The value of
a postfixa post-increment-expression or post-decrement-expression E is the value obtained by applying the lvalue-to-rvalue conversion (7.3.2 [conv.lval]) to its operand, which is the postfix-expression.++expression[Note: The value obtained is a copy of the original value. — end note ]
The operand shall be a modifiable lvalue. The type of the operand shall be an arithmetic type other than cv
bool, or a pointer to a complete object type. An operand with volatile-qualified type is deprecated; see D.4 [depr.volatile.type]. The value of the operand object is modified (3.1 [defns.access]) as if it were the operand of
- (1.1) the prefix
++operator (7.6.2.3 [expr.pre.incr]) if E is a post-increment-expression, or- (1.2) the prefix
--operator if E is a post-decrement-expression.The value computation of
theE is sequenced before the modification of the operand object. With respect to an indeterminately-sequenced function call, the operation of++expressionpostfixE is a single evaluation.++[Note: Therefore, a function call cannot intervene between the lvalue-to-rvalue conversion and the side effect associated with any single
postfixpost-increment-expression or post-decrement-expression. — end note ]++operatorThe result is a prvalue. The type of the result is the cv-unqualified version of the type of the operand.
Remove 7.6.1.6 [expr.post.incr] paragraph 2:
2 The operand of postfix
--is decremented analogously to the postfix++operator.[Note: For prefix increment and decrement, see 7.6.2.3 [expr.pre.incr]. — end note ]
Change 7.6.1.7 [expr.dynamic.cast] paragraph 1 as follows:
dynamic-cast-expression:dynamic_cast<type-id>(expression)1 The result of
the expressiona dynamic-cast-expression is the result of converting thedynamic_cast<T>(v)expressionexpressionvto the typeTdesignated by the type-id.Tshall be a pointer or reference to a complete class type, or “pointer to cvvoid”. Thedynamic_castoperator shall not cast away constness (7.6.1.11 [expr.const.cast]).[Note: The
>token following the type-id can be the product of replacing a>>token by two consecutive>tokens (13.3 [temp.names]). — end note ]
Change 7.6.1.8 [expr.typeid] paragraph 1 as follows:
typeid-expressiontypeid(expression)
typeid(type-id)1 The result of a
typeid-expression is an lvalue of static typetypeidexpressionconst std::type_info(17.7.3 [type.info]) and dynamic typeconst std::type_infoorconstname where name is an implementation-defined class publicly derived fromstd::type_infowhich preserves the behavior described in 17.7.3 [type.info].48 The lifetime of the object referred to by the lvalue extends to the end of the program. Whether or not the destructor is called for thestd::type_infoobject at the end of the program is unspecified.
Change 7.6.1.9 [expr.static.cast] paragraph 1 as follows:
static-cast-expression
static_cast<type-id>(expression)1 The result of
the expressiona static-cast-expression is the result of converting thestatic_cast<T>(v)expressionexpressionvto the typeTdesignated by the type-id. IfTis an lvalue reference type or an rvalue reference to function type, the result is an lvalue; ifTis an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue.[Note: The
>token following the type-id can be the product of replacing a>>token by two consecutive>tokens (13.3 [temp.names]). — end note ]
Change 7.6.1.10 [expr.reinterpret.cast] paragraph 1 as follows:
reinterpret-cast-expressionreinterpret_cast<type-id>(expression)1 The result of
the expressiona reinterpret-cast-expression is the result of converting thereinterpret_cast<T>(v)expressionexpressionvto the typeTdesignated by the type-id. IfTis an lvalue reference type or an rvalue reference to function type, the result is an lvalue; ifTis an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue and the lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard conversions are performed on the expressionv. Conversions that can be performed explicitly usingreinterpret_castare listed below. No other conversion can be performed explicitly usingreinterpret_cast.[Note: The
>token following the type-id can be the product of replacing a>>token by two consecutive>tokens (13.3 [temp.names]). — end note ]
Change 7.6.1.11 [expr.const.cast] paragraph 1 as follows:
const-cast-expressionconst_cast<type-id>(expression)1
The result of theThe result of a const-cast-expression is the result of converting the expressionconst_cast<T>(v)is of typeT.vto the typeTdesignated by the type-id. IfTis an lvalue reference to object type, the result is an lvalue; ifTis an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue and the lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard conversions are performed on the expressionv. The temporary materialization conversion is not performed onv, other than as specified below. Conversions that can be performed explicitly usingconst_castare listed below. No other conversion shall be performed explicitly usingconst_cast.[Note: The
>token following the type-id can be the product of replacing a>>token by two consecutive>tokens (13.3 [temp.names]). — end note ]
Change 12.2.2.2.1 [over.match.call.general] paragraph 1 as follows:
1 In a function call (7.6.1.3 [expr.call])
postfix-expression(expression-listopt)
ifIf the postfix-expression of a function-call-expression names at least one function or function template, overload resolution is applied as specified in 12.2.2.2.2 [over.call.func]. If the postfix-expression denotes an object of class type, overload resolution is applied as specified in 12.2.2.2.3 [over.call.object].
Apply the following changes to the entire subclause 12.2.2.2.2 [over.call.func]:
1 Of interest in 12.2.2.2.2 [over.call.func] are only those function calls in which the postfix-expression ultimately contains an id-expression or splice-expression that designates one or more functions. Such a postfix-expression, perhaps nested arbitrarily deep in parentheses, has one of the following forms:
postfix-expression:postfix-expression.id-expression
postfix-expression.splice-expression
postfix-expression->id-expression
postfix-expression->splice-expression
id-expression
splice-expressionThese represent two syntactic subcategories of function calls: qualified function calls and unqualified function calls.
2
In qualified function calls, the function is designated by anA qualified function call is a function-call-expression whose (possibly parenthesized) postfix-expression is a class-member-access-expression whose id-expression or splice-expression Epreceded by andesignates a function. Since the construct->or.operatorA->Bis generally equivalent to(*A).B, the rest of Clause 12 [over] assumes, without loss of generality, that all member function calls have been normalized to the form that uses an object and the.operator. Furthermore, Clause 12 [over] assumes that the postfix-expression that is the left operand of the.operator has type “cvT” whereTdenotes a class.94 The set of candidate functions either is the set found by name lookup (6.5.2 [class.member.lookup]) if E is an id-expression or is the set determined as specified in 7.5.9 [expr.prim.splice] if E is a splice-expression. The argument listis the expression-list in the callconsists of the arguments of the function-call-expression augmented by the addition of the left operand of the.operator in the normalized member function call as the implied object argument (12.2.2 [over.match.funcs]).3
In unqualified function calls, the function is designated byAn unqualified function call is a function-call-expression whose (possibly parenthesized) postfix-expression is an id-expression or a splice-expression E which designates a function. The set of candidate functions either is the set found by name lookup (6.5 [basic.lookup]) if E is an id-expression or is the set determined as specified in 7.5.9 [expr.prim.splice] if E is a splice-expression. The set of candidate functions consists either entirely of non-member functions or entirely of member functions of some classT. In the former case or if E is either a splice-expression or the address of an overload set, the argument listis the same as the expression-list in the callconsists of the arguments of the function-call-expression. Otherwise, the argument listis the expression-list in the callconsists of the arguments of the function-call-expression augmented by the addition of an implied object argument as in a qualified function call. [. . .][Example: [. . .] — end example ]
[ Drafting note: Does the definition of unqualified function call
cover sizeof(((***func))());,
which is accepted by all implementations (Compiler Explorer)? ]
Change 12.2.2.2.3 [over.call.object] paragraph 1 as follows:
1 If the postfix-expression E
in the function call syntaxof a function-call-expression evaluates to a class object of type “cvT”, then the set of candidate functions includes at least the function call operators ofT. The function call operators ofTare the results of a search for the nameoperator()in the scope ofT.
Change 12.4.4 [over.call] paragraph 1 as follows:
1 A function call operator function is a function named
operator()that is a member function with an arbitrary number of parameters. It may have default arguments. Foran expression of the forma function-call-expressionpostfix-expression(expression-listopt)
wherewhose the postfix-expression is of class type, the operator function is selected by overload resolution (12.2.2.2.3 [over.call.object]). If a surrogate call function is selected, let e be the result of invoking the corresponding conversion operator function on the postfix-expression;the expression is interpreted as
e(expression-listopt)Otherwise, the expression is interpreted as
postfix-expression.operator ()(expression-listopt)
[ Drafting note: Should we keep quoting the grammar of function-call-expression to make it clear where expression-list comes from? The same applies to [over.sub] changes below. ]
Change 12.4.5 [over.sub] paragraph 1 as follows:
1 A subscripting operator function is a member function named
operator[]with an arbitrary number of parameters. It may have default arguments. Foran expression of the forma subscript-expressionpostfix-expression[expression-listopt]the operator function is selected by overload resolution (12.2.2.3 [over.match.oper]). If a member function is selected, the expression is interpreted as
postfix-expression.operator[](expression-listopt)
Change 12.4.6 [over.ref] paragraph 1 as follows:
1 A class member access operator function is a function named
operator->that is a non-static member function taking no non-object parameters. Foran expressiona class-member-access-expression of the formpostfix-expression->templateopt id-expressionthe operator function is selected by overload resolution (12.2.2.3 [over.match.oper]), and the expression is interpreted as
(postfix-expression.operator->())->templateopt id-expressionAnalogously, for
an expressiona class-member-access-expression of the formpostfix-expression->splice-expressionthe operator function is selected by overload resolution, and the expression is interpreted as
(postfix-expression.operator->())->splice-expression
Change 6.3 [basic.def.odr] paragraph 3 as follows:
3 An expression or conversion is potentially evaluated unless it is an unevaluated operand (7.2.3 [expr.context]), a subexpression thereof, or a conversion in an initialization or conversion sequence in such a context. The set of potential results of an expression E is defined as follows:
- [. . .]
- (3.3) If E is a
class member access expression (7.6.1.5)class-member-access-expression of the form E1.templateopt E2, where E2 designates a non-static data member or a direct base class relationship, the set contains the potential results of E1.- (3.4) If E is a
class member access expressionclass-member-access-expression naming a static data member, the set contains the id-expression designating the data member.- [. . .]
Change 6.3 [basic.def.odr] paragraph 5 as follows:
5 A variable is named by an expression if the expression is an id-expression or splice-expression (7.5.9 [expr.prim.splice]) that designates it. A variable
xthat is named by a potentially evaluated expression N that appears at a point P is odr-used by N unless
- (5.1)
xis a reference that is usable in constant expressions at P ([expr.const.init]), or- (5.2) N is an element of the set of potential results of an expression E, where
- (5.2.1) E is a discarded-value expression (7.2.3 [expr.context]) to which the lvalue-to-rvalue conversion is not applied, or
- (5.2.2)
xis a non-volatile object that is usable in constant expressions at P and has no mutable subobjects, and
- (5.2.2.1) E is a
class member access expression (7.6.1.5 [expr.ref])class-member-access-expression naming a non-static data member of reference type and whose object expression has non-volatile-qualified type, or- (5.2.2.2) the lvalue-to-rvalue conversion (7.3.2 [conv.lval]) is applied to E and E has non-volatile-qualified non-class type.
[Example: [. . .] — end example ]
Change 6.3 [basic.def.odr] paragraph 7 as follows:
7
*thisis odr-used ifthisappears as a potentially evaluated expression (including as the result of any implicit transformation to aclass member access expressionclass-member-access-expression (7.5.5.1 [expr.prim.id.general])).
Change 6.5.3 [basic.lookup.unqual] paragraph 4 as follows:
4 An unqualified name is a name that does not immediately follow a nested-name-specifier or the
.or->in aclass member access expression (7.6.1.5)class-member-access-expression, possibly after atemplatekeyword or~. Unless otherwise specified, such a name undergoes unqualified name lookup from the point where it appears.
Change 6.5.4 [basic.lookup.argdep] paragraph 1 as follows:
1 When the postfix-expression in a
function call (7.6.1.3 [expr.call])function-call-expression is an unqualified-id, and unqualified lookup (6.5.3 [basic.lookup.unqual]) for the name in the unqualified-id does not find any
- (1.1) declaration of a class member, or
- (1.2) function declaration inhabiting a block scope, or
- (1.3) declaration not of a function or function template
then lookup for the name also includes the result of argument-dependent lookup in a set of associated namespaces that depends on the types of the arguments (and for type template template arguments, the namespace of the template argument), as specified below.
[Example: [. . .] — end example ]
Change 6.5.4 [basic.lookup.argdep] paragraph 2 as follows:
[Note: For purposes of determining (during parsing) whether an expression is a postfix-expression
for a function callof a function-call-expression, the usual name lookup rules apply. In some cases a name followed by<is treated as a template-name even though name lookup did not find a template-name (see 13.3 [temp.names]). For example,int h; void g(); namespace N { struct A {}; template <class T> int f(T); template <class T> int g(T); template <class T> int h(T); } int x = f<N::A>(N::A()); // OK, lookup offfinds nothing,ftreated as template name int y = g<N::A>(N::A()); // OK, lookup ofgfinds a function,gtreated as template name int z = h<N::A>(N::A()); // error:h<does not begin a template-idThe rules have no effect on the syntactic interpretation of an expression. For example,
typedef int f; namespace N { struct A { friend void f(A &); operator int(); void g(A a) { int i = f(a); //fis the typedef, not the friend function: equivalent toint(a)} }; }Because the expression is not a
function callfunction-call-expression, argument-dependent name lookup does not apply and the friend functionfis not found. — end note ]
Change 6.5.5.1 [basic.lookup.qual.general] paragraph 2 as follows:
2 A member-qualified name is the (unique) component name (7.5.5.2 [expr.prim.id.unqual]), if any, of
- (2.1) an unqualified-id or
- (2.2) a nested-name-specifier of the form type-name
::or namespace-name::in the id-expression of a
class member access expression (7.6.1.5 [expr.ref])class-member-access-expression. [. . .][Note: [. . .] — end note ]
[Example: [. . .] — end example ]
Change 6.8.6.5.1 [basic.stc.dynamic.general] paragraph 2 as follows:
2 [. . .]
[Note: he implicit declarations do not introduce the names
std,std::size_t,std::align_val_t, or any other names that the library uses to declare these names. Thus, a new-expression, delete-expression, orfunction callfunction-call-expression that refers to one of these functions without importing or including the header<new>(17.6.2 [new.syn]) or importing a C++ library module (16.4.2.4 [std.modules]) is well-formed. However, referring tostdorstd::size_torstd::align_val_tis ill-formed unless a standard library declaration (17.2.1 [cstddef.syn], 17.6.2 [new.syn], 16.4.2.4 [std.modules]) of that name precedes (6.5.1 [basic.lookup.general]) the use of that name. — end note ][. . .]
Change 6.10.1 [intro.execution] paragraph 11 as follows:
11 When invoking a function f (whether or not the function is inline), every argument expression and the
postfix expressionpostfix-expression designating f are sequenced before every precondition assertion of f (9.4.1 [dcl.contract.func]), which in turn are sequenced before every expression or statement in the body of f, which in turn are sequenced before every postcondition assertion of f.
Change 7.2.1 [basic.lval] paragraph 4 as follows:
[Note: An expression is an xvalue if it is:
- [. . .]
- (4.5) a
class member access expressionclass-member-access-expression designating a non-static data member of non-reference type in which the object expression is an xvalue(7.6.1.5 [expr.ref]), or- [. . .]
[. . .]
— end note ][Example: [. . .] — end example ]
Add a new paragraph at the end of 7.5.4 [expr.prim.paren]:
1 A parenthesized expression
(E)is a primary expression whose type, result, and value category are identical to those of E. The parenthesized expression can be used in exactly the same contexts as those where E can be used, and with the same meaning, except as otherwise indicated.n A possibly parenthesized expression may be nested arbitrarily deep in parentheses.
[ Drafting note: Do we need a cross-reference to [implimits]/1.4? ]
Change 7.5.5.1 [expr.prim.id.general] paragraph 2 as folows:
2 If an id-expression E denotes a non-static non-type member of some class
Cat a point where the current class (7.5.3 [expr.prim.this]) isXand
- (2.1) E is potentially evaluated or
CisXor a base class ofX, and- (2.2) E is not the id-expression of a
class member access expression (7.6.1.5 [expr.ref])class-member-access-expression, and- (2.3) E is not the id-expression of a reflect-expression (7.6.2.10 [expr.reflect]), and
- (2.4) if E is a qualified-id, E is not the un-parenthesized operand of the unary
&operator (7.6.2.2 [expr.unary.op]),the id-expression is transformed into a
class member access expressionclass-member-access-expression using(*this)as the object expression. If this transformation occurs in the predicate of a precondition assertion of a constructor ofXor a postcondition assertion of a destructor ofX, the expression is ill-formed.[Note: If
Cis notXor a base class ofX, theclass member access expressionclass-member-access-expression is ill-formed. Also, if the id-expression occurs within a static or explicit object member function, the class member access is ill-formed. — end note ]This transformation does not apply in the template definition context (13.8.3.2 [temp.dep.type]).
[Example: [. . .] — end example ]
Change 7.5.5.1 [expr.prim.id.general] paragraph 3 as folows:
3 If an id-expression E denotes a variant member M of an anonymous union (11.5.2 [class.union.anon]) U:
(3.1) If U is a non-static data member, E refers to M as a member of the lookup context of the terminal name of E (after any implicit transformation to a
class member access expressionclass-member-access-expression).[Example:
o.xis interpreted aso.u.x, where u names the anonymous union member. — end example ][. . .]
Change 7.5.5.2 [expr.prim.id.unqual] paragraph 4 as folows:
4 if
- (4.1) the unqualified-id appears in a lambda-expression at program point P,
- (4.2) the entity is a local entity (6.1 [basic.pre]) or a variable declared by an init-capture (7.5.6.3 [expr.prim.lambda.capture]),
- (4.3) naming the entity within the compound-statement of the innermost enclosing lambda-expression of P, but not in an unevaluated operand, would refer to an entity captured by copy in some intervening lambda-expression, and
- (4.4) P is in the function parameter scope, but not the parameter-declaration-clause, of the innermost such lambda-expression E,
then the type of the expression is the type of a
class member access expression (7.6.1.5 [expr.ref])class-member-access-expression naming the non-static data member that would be declared for such a capture in the object parameter (9.3.4.6 [dcl.fct]) of the function call operator of E.[Note: [. . .] — end note ]
[Example: [. . .] — end example ]
Change 7.5.5.5 [expr.prim.id.dtor] paragraph 2 as follows:
2 If the id-expression names a pseudo-destructor,
Tshall be a scalar type and the id-expression shall appear as the right operand of aclass member access (7.6.1.5 [expr.ref])class-member-access-expression that forms the postfix-expression of afunction call (7.6.1.3 [expr.call])function-call-expression.
Change 7.5.9 [expr.prim.splice] paragraph 4 as follows:
4 For a splice-expression of the form template splice-specialization-specifier, the splice-specifier of the splice-specialization-specifier shall designate a template T.
- [. . .]
[Note: Class members are accessible from any point when designated by splice-expressions (11.8.3 [class.access.base]). A
class member access expression (7.6.1.5)class-member-access-expression whose right operand is a splice-expression is ill-formed if the left operand (considered as a pointer) cannot be implicitly converted to a pointer to the designating class of the right operand. — end note ]
Change 7.6.2.2 [expr.unary.op] paragraph 3 as follows:
3 The operand of the unary
&operator shall be an lvalue of some typeT.
(3.1) If the operand is a qualified-id or splice-expression designating a non-static member m, other than an explicit object member function,
mshall be a direct member of some classCthat is not an anonymous union. The result has type “pointer to member of classCof typeT” and designatesC::m.[Note: A qualified-id that names a member of a namespace-scope anonymous union is considered to be a
class member access expression (7.5.5.1)class-member-access-expression and cannot be used to form a pointer to member. — end note ][. . .]
Change 7.6.20 [expr.comma] paragraph 2 as follows:
[Note: In contexts where the comma token is given special meaning (e.g.,
function calls (7.6.1.3)function-call-expressions,subscript expressions (7.6.1.2)subscript-expressions,lists of initializers (9.5)initializer-lists, or template-argument-lists (13.3 [temp.names])), the comma operator as described in this subclause can appear only in parentheses.— end note ][Example: [. . .] — end example ]
Change [expr.const.core] paragraph 2 as follows:
2 An expression E is a core constant expression unless the evaluation of E, following the rules of the abstract machine (6.10.1 [intro.execution]), would evaluate one of the following:
- (2.1)
this(7.5.3 [expr.prim.this]), except
- [. . .]
- (2.1.2) when appearing as the postfix-expression of an implicit or explicit
class member access expression (7.6.1.5 [expr.ref])class-member-access-expression;- [. . .]
- [. . .]
- (2.18) an invocation of a destructor (11.4.7 [class.dtor]) or a
function callfunction-call-expression whose postfix-expression names a pseudo-destructor (7.6.1.3 [expr.call]), in either case for an object whose lifetime did not begin within the evaluation of E;- [. . .]
Change 9.3.4.7 [dcl.fct.default] paragraph 9 as follows:
9 A default argument is evaluated each time the function is called with no argument for the corresponding parameter. A parameter shall not appear as a potentially evaluated expression in a default argument.
[Note: [. . .] — end note ]
[Example: [. . .] — end example ]
A non-static member shall not be designated in a default argument unless
- (9.1) it is designated by the id-expression or splice-expression of a
class member access expression (7.6.1.5 [expr.ref])class-member-access-expression,- [. . .]
[. . .]
Change 11.10.1 [class.compare.default] paragraph 5 as follows:
5 The direct base class subobjects of
C, in the order of their declaration in the base-specifier-list ofC, followed by the non-static data members ofC, in the order of their declaration in the member-specification ofC, form a list of subobjects. In that list, any subobject of array type is recursively expanded to the sequence of its elements, in the order of increasing subscript. Letxi be an lvalue denoting the ith element in the expanded list of subobjects for an objectx(of length n), wherexi is formed by a sequence of derived-to-base conversions (12.2.4.2 [over.best.ics]),class member access expressions (7.6.1.5 [expr.ref])class-member-access-expressions, andarray subscript expressions (7.6.1.2 [expr.sub])subscript-expressions applied tox.
Change [temp.names] paragraph 3 as follows:
3 A
<is interpreted as the delimiter of a template-argument-list if either
- (3.1) it follows a splice-specifier that either
- (3.2) it follows a name that is not a conversion-function-id and
- (3.2.1) that follows the keyword
templateor a~after a nested-name-specifier or in aclass member access expressionclass-member-access-expression, or- [. . .]
[Note: [. . .] — end note ]
[Example: [. . .] — end example ]
Change 13.8.3.1 [temp.dep.general] paragraph 2 as follows:
2 A
dependent calldependent call isan expressiona function-call-expression, possibly formed as a non-member candidate for an operator (12.2.2.3 [over.match.oper]),of the form:postfix-expression(expression-listopt)
where thewhose postfix-expression is an unqualified-id and
- (2.1) any of the expressions in the expression-list is a pack expansion (13.7.4 [temp.variadic]), or
- (2.2) any of the expression or brace-init-lists in the expression-list is type-dependent (13.8.3.3 [temp.dep.expr]), or
- (2.3) the unqualified-id is a template-id in which any of the template arguments depends on a template parameters.
The component name of an unqualified-id (7.5.5.2 [expr.prim.id.unqual]) is dependent if
- (2.4) it is a conversion-function-id whose conversion-type-id is dependent, or
- (2.5) it is
operator=and the current class is a templated entity, or- (2.6) the unqualified-id is the postfix-expression in a dependent call.
[Note: [. . .] — end note ]
Do not change 13.8.3.3 [temp.dep.expr] paragraph 3:
3 [. . .] Expressions of the following forms are type-dependent only if the type specified by the type-id, simple-type-specifier, typename-specifier, or new-type-id is dependent, even if any subexpression is type-dependent:
simple-type-specifier(expression-listopt)
simple-type-specifier braced-init-list
typename-specifier(expression-listopt)
typename-specifier braced-init-list
::optnewnew-placementopt new-type-id new-initializeropt
::optnewnew-placementopt(type-id)new-initializeropt
dynamic_cast<type-id>(expression)
static_cast<type-id>(expression)
const_cast<type-id>(expression)
reinterpret_cast<type-id>(expression)
(type-id)cast-expression
Change 13.8.3.3 [temp.dep.expr] paragraph 4 as follows:
4 Expressions of the following forms are never type-dependent (because the type of the expression cannot be dependent):
literal
sizeofunary-expression
sizeof(type-id)
sizeof...(identifier)
alignof(type-id)
typeid(expression)
typeid(type-id)
typeid-expression
::optdeletecast-expression
::optdelete[]cast-expression
throwassignment-expressionopt
noexcept(expression)
requires-expression
reflect-expression[Note: For the standard library macro
offsetof, see 17.2 [support.types]. — end note ]
Change 13.8.3.3 [temp.dep.expr] paragraph 5 as follows:
5 A
class member access expression (7.6.1.5 [expr.ref])class-member-access-expression is type-dependent if
Do not change 13.8.3.4 [temp.dep.constexpr] paragraphs 2 and 3:
2 [. . .] Expressions of the following form are value-dependent if the unary-expression or expression is type-dependent or the type-id is dependent:
sizeofunary-expression
sizeof(type-id)
typeid(expression)
typeid(type-id)
alignof(type-id)[Note: For the standard library macro
offsetof, see 17.2 [support.types]. — end note ]3 Expressions of the following form are value-dependent if either the type-id, simple-type-specifier, or typename-specifier is dependent or the expression or cast-expression is value-dependent or any expression in the expression-list is value-dependent or any assignment-expression in the braced-init-list is value-dependent:
simple-type-specifier(expression-listopt)
typename-specifier(expression-listopt)
simple-type-specifier braced-init-list
typename-specifier braced-init-list
static_cast<type-id>(expression)
const_cast<type-id>(expression)
reinterpret_cast<type-id>(expression)
dynamic_cast<type-id>(expression)
(type-id)cast-expression
Change 13.10.3.6 [temp.deduct.type] paragraph 23 as follows:
23 The template-argument corresponding to a template template parameter is deduced from the type of the template-argument of a class template specialization used in the argument list of a function call (12.2.2.2.2 [over.call.func]).
[Example: [. . .] — end example ]
Change 14.5 [except.spec] paragraph 5 as follows:
5 An expression E is potentially-throwing if
- (5.1) E is a
function call (7.6.1.3 [expr.call])function-call-expression whose postfix-expression has a function type, or a pointer-to-function type, with a potentially-throwing exception specification, or- [. . .]
Change 16.3.3.4 [alg.func.obj] paragraph 2 as follows:
2 For an algorithm function object
o, let S be the corresponding set of function templates. Then for any sequence of argumentsargs . . .,o(args . . . )is expression-equivalent tos(args . . . ), where the result of name lookup forsis the overload set S.[Note: Algorithm function objects are not found by argument-dependent name lookup (6.5.4 [basic.lookup.argdep]). When found by unqualified name lookup (6.5.3 [basic.lookup.unqual]) for the postfix-expression in a
function call (7.6.1.3 [expr.call])function-call-expression, they inhibit argument-dependent name lookup.[Example:— end note ]void foo() { using namespace std::ranges; std::vector<int> vec{1,2,3}; find(begin(vec), end(vec), 2); // #1 }The
function call expressionfunction-call-expression at #1 invokesstd::ranges::find, notstd::find. — end example ]
Change 17.8.2.2 [support.srcloc.cons] paragraph 1 as follows:
static consteval source_location current() noexcept;1 Returns:
- (1.1) When invoked by a
function callfunction-call-expression whose postfix-expression is a (possibly parenthesized) id-expression namingcurrent, returns asource_locationwith an implementation-defined value. [. . .]- [. . .]
Change 22.10.1 [function.objects.general] paragraph 1 as follows:
1 A function object type is an object type (6.9.1 [basic.types.general]) that can be the type of the postfix-expression in a
function call (7.6.1.3 [expr.call], 12.2.2.2 [over.match.call])function-call-expression.174
Change C.2.3 [diff.cpp20.expr] paragraph 2 as follows:
Affected subclause: 7.6.1.2 [expr.sub]
Change: Change the meaning of comma in
subscript expressionssubscript-expressions.Rationale: Enable repurposing a deprecated syntax to support multidimensional indexing.
Effect on original feature: Valid C++ 2020 code that uses a comma expression within a
subscript expressionsubscript-expression may fail to compile.[Example:— end example ]arr[1, 2] // was equivalent toarr[(1, 2)], // now equivalent toarr.operator[](1, 2)or ill-formed