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

A lvalue-to-rvalue conversion is not necessary to be required in [dcl.init.ref#5.3] #4753

Closed
xmh0511 opened this issue Jul 16, 2021 · 1 comment · Fixed by #4804
Closed
Assignees

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jul 16, 2021

Otherwise, if the initializer expression

  • is an rvalue (but not a bit-field) or function lvalue and “cv1 T1” is reference-compatible with “cv2 T2”, or
  • has a class type (i.e., T2 is a class type), where T1 is not reference-related to T2, and can be converted to an rvalue or function lvalue of type “cv3 T3”, where “cv1 T1” is reference-compatible with “cv3 T3” (see [over.match.ref]),

then the value of the initializer expression in the first case and the result of the conversion in the second case is called the converted initializer. [....]

the value of the initializer expression sounds a bit strange, it seems that an lvalue-to-rvalue conversion would apply to the original initializer expression(if necessary) to convert it be a prvalue in order to read the value, as per [basic.lval#5]

The result of a prvalue is the value that the expression stores into its context; a prvalue that has type cv void has no result. A prvalue whose result is the value V is sometimes said to have or name the value V.

In my mind, an "rvalue" is either a "xvalue" or a "prvalue", Its glvalue(possible-converted) could be directly bound to reference. Why do we say "the value of the initializer expression in the first case" here? We just need to say that

the initializer expression in the first case...

is sufficient.

The wording "the value of the initializer expression" keeps using since the c++11 standard, that is

then the reference is bound to the value of the initializer expression in the first case and to
the result of the conversion in the second case (or, in either case, to an appropriate base class
subobject).

But, in that document, the value of an expression seems to be not well-defined and has a different meaning in the current standard, hence, the wording is not suitable now.

@xmh0511 xmh0511 changed the title A lvalue-to-rvalue conversion is necessary in [dcl.init.ref#5.3]? A lvalue-to-rvalue conversion is not necessary to be required in [dcl.init.ref#5.3] Jul 19, 2021
@xmh0511
Copy link
Contributor Author

xmh0511 commented Aug 12, 2021

@jensmaurer Could you please take a look at this issue?

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.

2 participants