Skip to content

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

@xmh0511

Description

@xmh0511

[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions