cplusplus / CWG

Core Working Group
23 stars 7 forks source link

CWG2762 [over.match.funcs.general] p4 The definition of the type of the implicit parameter object is not accurate #358

Closed xmh0511 closed 9 months ago

xmh0511 commented 1 year ago

Full name of submitter (unless configured in github; will be published with the issue): Jim X

[over.match.funcs.general] p4 says:

For implicit object member functions, the type of the implicit object parameter is

  • [...]

where X is the class of which the function is a member and cv is the cv-qualification on the member function declaration.

However, [class.derived.general] p2 says:

Members of a base class are also members of the derived class.

Consider this example:

struct Base{
    void show(){}
};
struct S:Base{
};
int main(){
    S{}.show();
}

What's the type of the implicit parameter object of show in this case? According to the current wording, X is S because show is the member of S.

Suggested Resolution

We may want to say

where X is the class in which the function is introduced by the member declaration

jensmaurer commented 1 year ago

CWG2762