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

Clean up of discarded-value expressions #3909

Closed
wants to merge 1 commit into from

Conversation

sdkrystian
Copy link
Contributor

@sdkrystian sdkrystian commented Mar 25, 2020

This fixes a few issues with discarded-value expressions:

  1. The current wording in [expr.prop] states that the temporary materialization conversion is applied to prvalues of void type, which makes discarded-value expressions of void type ill-formed (temporary materialization conversion requires a complete type). This fixes that, and ensures that all discarded-value expressions are evaluated (with the exception of unevaluated operands, of course)

  2. In [expr.static.cast], grammatical term expression is used where "operand" is much clearer, and more consistent with the rest of the wording. Additionally, specifying that the operand of the cast becomes a discarded-value expression is much clearer than saying "the expression", since it could be interpreted as saying that the whole expression is a discarded value expression (it shouldn't, since the operand itself needs to be temporarily materialized and evaluated). A note is also added to clarify that the conversion will be an expression of type void with no result.

  3. A return statement can sometimes have an operand of type void, in which case it should be a discarded-value expression, but this is not specified.

As for the editorial nature of this, the intent here is pretty clear :)

Will rename commit after edits :)

source/statements.tex Outdated Show resolved Hide resolved
Comment on lines 462 to 467
\begin{note}
If the expression is an lvalue of
class type, it must have a volatile copy constructor to initialize the
temporary object that is the result object of the lvalue-to-rvalue
conversion.
\end{note}
Copy link
Member

Choose a reason for hiding this comment

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

This note is quite distant from "the expression" that it's talking about, which is the original discarded-value expression prior to any conversions. Can we get it a bit closer to the wording above that talks about introducing an lvalue-to-rvalue conversion?

Copy link
Member

Choose a reason for hiding this comment

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

But the temporary materialization conversion is the one that actually creates the object (and needs the volatile copy constructor).

Suggestion: Say "If the original expression" and replace "lvalue-to-rvalue conversion" with "temp. mat. conv." and move "The expression is evaluated and its result (if any) is discarded." to after the note.

@jensmaurer jensmaurer added the changes requested Changes to the wording or approach have been requested and not yet applied. label Sep 19, 2020
@wg21bot wg21bot added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes to the wording or approach have been requested and not yet applied. 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.

None yet

4 participants