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

What is the value category of an expression denoting base class subobject in reference binding? #4917

Open
xmh0511 opened this issue Sep 18, 2021 · 2 comments
Labels
cwg Issue must be reviewed by CWG.

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Sep 18, 2021

In [class.copy.ctor] p14

Let x be either the parameter of the constructor or, for the move constructor, an xvalue referring to the parameter. [...]

-[...]

  • otherwise, the base or member is direct-initialized with the corresponding base or member of x.

What is the value category of the corresponding base of x when overload resolution selected the corresponding constructor? In other words, consider the following simplified example

struct B{};
struct A:B{};
void fun(B const&);  // #1
void fun(B const&&); // #2
int main() {
  A a;
  fun(std::move(a));
}

The selection between #1 and #2 requires the applying of [over.ics.rank#3.2.3]

S1 and S2 include reference bindings ([dcl.init.ref]) and neither refers to an implicit object parameter of a non-static member function declared without a ref-qualifier, and S1 binds an rvalue reference to an rvalue and S2 binds an lvalue reference

While [dcl.init.ref#5.3] says

In any case, the reference binds to the resulting glvalue (or to an appropriate base class subobject).

Regardless of #1 or #2, the references both bind to the base class subobject, which requires us to determine what the value category of an expression denoting that base class subobject is. This is underspecified in the current standard.

Although, the object of type A is denoted by a xvalue expression, however, that xvalue denotes object A rather than object B, as per [basic.lval#1.3].

@jensmaurer jensmaurer added the cwg Issue must be reviewed by CWG. label Sep 18, 2021
@jensmaurer
Copy link
Member

Nothing that can be done here editorially, I'd say.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Sep 18, 2021

Well, look forward to a CWG review, give an opportunity to clarify this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG.
Projects
None yet
Development

No branches or pull requests

2 participants