C++ Logo


Advanced search

Re: [std-proposals] Contradiction about this parameter in the C++ standard

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Mon, 18 Apr 2022 20:57:39 +0100
On Mon, 18 Apr 2022 at 20:07, language.lawyer--- via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On 18/04/2022 19:45, Anoop Rana via Std-Proposals wrote:
> > we know that if we have a function parameter named `var`, then the
> > value category of that parameter `var`(as an expression) is an *lvalue*.
> We know this about `var`s which are id-expressions.
> > Thus, reading the 2nd quoted statement above(that implies that a
> non-static
> > member function has a `this` parameter), the same should apply to the
> > `this` parameter.
> `this` is a separate grammar production which is not an id-expression.
> Thus, your reasoning is trivially incorrect.
> But it doesn't mean there is no [editorial] defect in the wording. «the
> `this` parameter of the function» sounds really weird.

Yes, the language in [expr.call]/4 is archaic ("shall" properly denotes
requirements on the user, not the implementation) and I think you're
correct that it's defective; there is no `this` parameter to initialize.

I don't have pre-ISO specifications to hand, but I believe that prior to
C++98 `this` was indeed a parameter (and was assignable, to boot). This SO
question <https://stackoverflow.com/q/7557406/567292> has some interesting

I suppose that paragraph <https://eel.is/c++draft/expr.call#7.sentence-4> (and
the following Note) should be struck entirely. Oddly, from what I can tell
it was introduced between C++98 and C++03, which would make it defective
from its original introduction.

Received on 2022-04-18 19:57:51