Title
Meaning of unqualified-ids vs. coroutine parameters
Status
open
Section
7.5.5.2 [expr.prim.id.unqual]
Submitter
Joshua Berne

Created on 2025-02-25.00:00:00 last changed 1 week ago

Messages

Date: 2025-12-01.22:19:45

Possible resolution:

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

    The If the unqualified-id appears in the function body of a coroutine and denotes (6.5.3 [basic.lookup.unqual]) a coroutine parameter of that coroutine, the result is the copy of that parameter (9.6.4 [dcl.fct.def.coroutine]); otherwise the result is the entity denoted by the unqualified-id (6.5.3 [basic.lookup.unqual]).

    If

    • the unqualified-id appears in a lambda-expression at program point P,
    • ...
    then the initial type of the expression is the type of a class member access expression (7.6.1.5 [expr.ref]) 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 3: If E is not declared mutable, the type of such an identifier will typically be const qualified. —end note]

  2. Remove 7.5.5.2 [expr.prim.id.unqual] paragraph 5:

    Otherwise, if the unqualified-id names a coroutine parameter, the type of the expression is that of the copy of the parameter (9.6.4 [dcl.fct.def.coroutine]), and the result is that copy.
  3. Move 7.5.5.2 [expr.prim.id.unqual] paragraph 9 and paragraph 10 and to immediately after paragraph 4 and change as follows:

    Otherwise, if the entity is a template parameter object for a template parameter of type T (13.2 [temp.param]), the initial type of the expression is const T.

    In all other cases, the initial type of the expression is the type of the entity result.

  4. Change 7.5.5.2 [expr.prim.id.unqual] paragraph 6 and paragraph 7 as follows:

    Otherwise, if the unqualified-id names a result binding (9.4.2 [dcl.contract.res]) attached to a function f with return type U,

    • if U is “reference to T”, then the type of the expression is const T;
    • otherwise, the type of the expression is const U.

    If the initial type of the expression is "reference to T" for some type T, it is adjusted to be T.

    Otherwise, if If the unqualified-id appears in the predicate of a contract assertion C (6.11 [basic.contract]) and , the entity is

    • a variable declared outside of C of object type T,
    • a variable or template parameter declared outside of C of type “reference to T”, or
    • a structured binding of type T whose corresponding variable is declared outside of C, or
    • a result binding (9.4.2 [dcl.contract.res]),
    and the (possibly adjusted) initial type of the expression is T, then the type of the expression is const T; otherwise the type of the expression is T.

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

    [Note 4: The type will be adjusted as described in 7.2.2 [expr.type] if it is cv-qualified or is a reference type. —end note]
Date: 2025-11-30.09:04:42

(From submission #674.)

Subclause 7.5.5.2 [expr.prim.id.unqual] paragraph 5 indiscriminately refers to a "coroutine parameter", even though a coroutine is only identified as such within its body and not, for example, in the exception-specification.

Subclause 7.5.5.2 [expr.prim.id.unqual] paragraph 7 (constification in predicates of contract assertions) ought to apply even in the case of coroutine parameters, but currently does not.

For the constification of lambda captures (7.5.5.2 [expr.prim.id.unqual] paragraph 4), the result ought to still refer to the coroutine parameter copy.

History
Date User Action Args
2025-11-30 08:59:23adminsetmessages: + msg8426
2025-02-25 00:00:00admincreate