Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[class.access.base] p6 Unclear about the cv-qualification #4952

Open
xmh0511 opened this issue Sep 30, 2021 · 0 comments · May be fixed by #5068
Open

[class.access.base] p6 Unclear about the cv-qualification #4952

xmh0511 opened this issue Sep 30, 2021 · 0 comments · May be fixed by #5068

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Sep 30, 2021

[class.access.base] p6

If a class member access operator, including an implicit “this->”, is used to access a non-static data member or non-static member function, the reference is ill-formed if the left operand (considered as a pointer in the “.” operator case) cannot be implicitly converted to a pointer to the naming class of the right operand.

struct A{
   int a = 0;
};
struct B: A{
};
const B b;
(&b)->A::a;

The naming class of the right operand is class B while the left operand is a pointer to const B, from a pointer to const B to a pointer to A discards the cv-qualification, hence the implicit conversion cannot be done. It is not the intent of this rule, however, it is not clear in this wording about whether considering the cv-qualification when we say implicit conversions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant