What is the value category of an expression denoting base class subobject in reference binding?
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
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].
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read [class.copy.ctor] p14, [over.ics.rank#3.2.3], and [dcl.init.ref#5.3], then reproduce the question with the provided B/A example and compare overloads #1 and #2. Done means determining the value category of the corresponding base subobject and identifying the needed standard clarification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100