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

[class.copy.elision] Move specification of altered overload resolution #3998

Closed
wants to merge 1 commit into from

Conversation

jensmaurer
Copy link
Member

@jensmaurer jensmaurer commented May 14, 2020

(which prefers moving over copying) to [dcl.init] and [expr.call].
Also add and adjust cross-references in [stmt.return],
[stmt.return.coroutine] and [except.throw].

Fixes #3818

(which prefers moving over copying) to [dcl.init] and [expr.call].
Also add and adjust cross-references in [stmt.return],
[stmt.return.coroutine] and [except.throw].
For result-initialization,
overload resolution is first performed as if the operand were an rvalue.
For any other initialization, or if the first overload resolution fails,
overload resolution is performed again without altering value categories.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, it's unclear what the word "again" is doing here.

of the innermost \grammarterm{try-block} or \grammarterm{function-try-block}
(if any)
whose \grammarterm{compound-statement} or \grammarterm{ctor-initializer}
encloses the \grammarterm{throw-expression},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/,/./

@@ -6629,102 +6629,6 @@
move construction from the object with automatic storage duration to \tcode{t2} that is elided.
\end{example}

\pnum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, this refactoring merge-conflicts with the paper D2266 I've just started writing to clean up the semantics of implicit move. See https://quuxplusone.github.io/draft/d2266-implicit-move-rvalue-ref.html (which will at some point become https://wg21.link/p2266, I expect).

So basically I'm not in favor of any such major wording-moving-around, until we've finished figuring out what the wording should say. At least it'd be nice to avoid duplicating it in multiple places.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fundamental concern with the status quo is that mandatory behavior is hidden in a "copy elision" section, without any first-order connection to where the grammar appears (stmt.return etc.) If your paper would do the move, that's fine as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, @zygoloid's review feedback on the above iteration of D2266 (R0 draft revision 1) is that my wording change is totally in the wrong place and ought to be somewhere more like https://eel.is/c++draft/basic.lval . (However, I can't find any current wording that clearly states "an id-expression is an lvalue"; if such wording existed, presumably that'd be the place for me to try changing.)

So I no longer object to shuffling this wording around.

The new term of art "result-initialization" is intended to be useful for more than just implicit-move, right? Because if D2266 ends up changing the value-category of an implicitly-movable id-expression, then we won't need any wording to describe implicit-move anymore.

Copy link
Member Author

@jensmaurer jensmaurer Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request (and the associated copy elision wording) will probably vanish entirely with your paper.

The wording that an id-expression is an lvalue is in [expr.prim.id.unqual] and siblings.

For result-initialization, overload resolution is first performed
as if the operand were an rvalue.
For any other initialization, or if the first overload resolution fails,
overload resolution is performed again without altering value categories.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again "again" doesn't seem to apply to non-result-initializations.

@@ -914,6 +915,10 @@
If the operand is a \grammarterm{braced-init-list} or an expression of non-\tcode{void} type,
\placeholder{S} is \placeholder{p}\tcode{.return_value(}\grammarterm{expr-or-braced-init-list}{}\tcode{)}.
The expression \placeholder{S} shall be a prvalue of type \tcode{void}.
\begin{note}
The operand might be moved instead of copied;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/might/can/, since we're doing that phrasing now?

that is either a non-volatile object or
an rvalue reference to a non-volatile object type.
The copy-initialization performed for one of the following is
known as \defn{result-initialization}:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely it's the initialization performed from one of these, right? It's not the initialization of the operand of the return statement; it's the initialization of the returned object, which is copy-initialized from the operand of the return.

Same comment down where you talk about a co_return statement "whose operand is subject to result-initialization." The operand is actually used to result-initialize whatever is passed to return_value.

@tkoeppe tkoeppe added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Dec 14, 2020
@jensmaurer
Copy link
Member Author

jensmaurer commented Mar 18, 2021

This pull request will be superseded by P2266 Simpler implicit move cplusplus/papers#968.

@tkoeppe
Copy link
Contributor

tkoeppe commented Aug 22, 2022

@jensmaurer Can we close this now?

@jensmaurer
Copy link
Member Author

Yes

@jensmaurer jensmaurer closed this Aug 22, 2022
@jensmaurer jensmaurer deleted the c18 branch August 22, 2022 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase The pull request needs a git rebase to resolve merge conflicts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[class.copy.elision] Specification of when implicit move occurs is potentially confusing
4 participants