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.copy.elision] p3 The return type in the first bullet should be restricted #4839
Comments
This is likely undefined behavior anyway, because you're returning a reference to a by-value parameter, which might be destroyed early [expr.call] p7. Also, the normative text says we try a move-construction in this case, which attempts to initialize an A& with xvalue referring to A, which fails, so we fall back to copy-initialization, which succeeds (as-if there was no implicitly movable entity). |
However, in this example, the reference A& could say is reference-compatible with the type of the operand. There is no overload resolution occurs here. Anyway, I think the rule just considers the case that the return type is object type.
This could cover all the cases rather than only the case used overload resolution(p.return_value( expr-or-braced-init-list |
Ah, the point is that that the copy/move section talks about overload resolution, but in your case, there is none. This entire section should only apply to objects. We say that in p1, but that context is arguably lost in p3. |
The concerns are probably invalidated by P2266R3 which considers reference return types... |
Consider this example
According to the rule, id-expression
x
in the return statement does name an implicitly movable entity. However, that rule indeed does not apply to this example. Shouldn't we restrict that the return type, in either case, shall be (possible cv-qualified) class type?The text was updated successfully, but these errors were encountered: