# std-proposals

From: language.lawyer_at <language.lawyer_at_[hidden]>
Date: Tue, 19 Apr 2022 10:57:55 +0300
On 19/04/2022 10:37, Edward Catmur wrote:
> On Tue, 19 Apr 2022 at 03:22, <language.lawyer_at_[hidden]> wrote:
>
>> On 18/04/2022 23:23, Edward Catmur wrote:
>>> On Mon, 18 Apr 2022 at 21:13, <language.lawyer_at_[hidden]> wrote:
>>>
>>>> On 18/04/2022 22:57, Edward Catmur wrote:
>>>>> I suppose that paragraph <

>>>> (and
>>>>> the following Note) should be struck entirely.
>>>> I'd say then we will not know which object [expr.prim.this]/1 speaks
>>>> («The keyword this names a pointer to the object for which an implicit
>>>> object member function is invoked»)
>>>>
>>>
>>> "the object for which an implicit object member function is invoked"
>> seems
>>> clear enough; per [expr.call]/2 it's the object expression on the LHS of
>>> the postfix expression (before the '.', '->', '.*' or '->*').
>>
>> If it is a base-class function, the object is the corresponding base class
>> subobject, isn't it?
>>
>
> Yes, but that's a problem with [expr.prim.this]/1; you can't have a pointer
> of base type pointing to an object of derived type. So that subclause is
> also defective, and should have appended ", or to its base class subobject,
> as appropriate".

I don't understand where the defect is.
When «the object for which function is invoked» is a base class subobject (and it is pointed to by this), there is no discrepancy between the type of this and the object's type.
«The object for which function is invoked» does not have to be «the result of the object expression».

> As for [expr.call]/7, there's no need to specify *how* the implementation
> is expected to come up with the value of the this pointer (although it
> could be a Note).

When you say that [expc.call]/2 defines the object for which the function is invoked, do you mean «the call is as a member of the class object referred to by the object expression»?

> e.g.:
>
> --- a/source/expressions.tex
> +++ b/source/expressions.tex
> @@ -1198,7 +1198,8 @@
> \indextext{\idxcode{this}}%
> The keyword \keyword{this} names a pointer to the object for which an
> implicit object member
> function\iref{class.mfct.non.static} is invoked or a non-static data member's
> -initializer\iref{class.mem} is evaluated.
> +initializer\iref{class.mem} is evaluated, or to its base class
> +subobject\iref{class.derived}, as appropriate.
>
> \pnum
> The \defnadj{current}{class} at a program point is
> @@ -3197,12 +3198,12 @@
> int x = f<int>(); // error: no argument for second
> function parameter
> \end{codeblock}
> \end{example}
> -If the function is an implicit object member
> -function, the \keyword{this} parameter of the function\iref{expr.prim.this}
> -is initialized with a pointer to the object of the call, converted
> -as if by an explicit type conversion\iref{expr.cast}.
> \begin{note}
> -There is no access or ambiguity checking on this conversion; the access
> +If the function is an implicit object member
> +function, within the function the \keyword{this}\iref{expr.prim.this}
> +names a pointer to the object of the call or to its base class subobject
> +as appropriate, as if converted by an explicit type conversion\iref{expr.cast}.
> +There is no access or ambiguity checking on this (notional)
> conversion; the access
> checking and disambiguation are done as part of the (possibly implicit)
> class member access operator.
> See~\ref{class.member.lookup}, \ref{class.access.base},
>