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

[expr] Clarify performing / applying standard conversions. #3955

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zygoloid
Copy link
Member

We previously had a conflict between wording demanding that certain
conversions be applied, and the definitions of the conversions saying
they could not be applied. We now distinguish two cases:

  • When we say that a conversion is applied, we're talking about a
    change to the resulting model of the program -- we mean that the
    conversion actually happens (and it had better be applicable).
  • When we say that a conversion is performed, we're talking about
    performing a process, which applies the conversion if possible and
    otherwise has no effect.

In addition, wording saying to perform the three kinds of conversion
from glvalue to prvalue have been changed to say that a prvalue operand
is expected.

We previously had a conflict between wording demanding that certain
conversions be applied, and the definitions of the conversions saying
they could not be applied. We now distinguish two cases:

 * When we say that a conversion is applied, we're talking about a
   change to the resulting model of the program -- we mean that the
   conversion actually happens (and it had better be applicable).
 * When we say that a conversion is performed, we're talking about
   performing a process, which applies the conversion if possible and
   otherwise has no effect.

In addition, wording saying to perform the three kinds of conversion
from glvalue to prvalue have been changed to say that a prvalue operand
is expected.
lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array},
and function-to-pointer\iref{conv.func} standard conversions are
performed on the argument expression.
In this case, argument expression is expected to be a prvalue\iref{basic.lval}.
Copy link
Member

Choose a reason for hiding this comment

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

missing "the"?

both operands were of array type
prior to these conversions\iref{depr.array.comp}.
an array-to-pointer\iref{conv.array} conversion
is applied to both operands\iref{depr.array.comp}.
Copy link
Member

Choose a reason for hiding this comment

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

The "operand" here means the original operand, but...


\pnum
The converted operands shall have arithmetic, enumeration, pointer,
The operands shall have arithmetic, enumeration, pointer,
Copy link
Member

Choose a reason for hiding this comment

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

The "operand" here means the converted prvalue operand. That's non-obvious.

@@ -235,9 +235,9 @@

\pnum
Whenever a glvalue appears as an operand of an operator that
expects a prvalue for that operand, the
expects a prvalue for that operand, an
Copy link
Member

Choose a reason for hiding this comment

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

Reading all the "expected to be" phrasings below makes me want to ask for "requires" here.
Example: "that requires a prvalue for that operand..." or "The operand is required to be a prvalue."
The "required" conveys better that, if you can't make it so, you're toast. (Just a slight wording preference, not a strong feeling.)

Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

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

We have lots more places where we expect a prvalue, but currently don't say so.
Example: expr.or, expr.bit.and, expr.xor.
Maybe we should say that "usual arithmetic conversions" yield prvalues? Currently, they only deal with types, not with value category.

The temporary materialization conversion\iref{conv.rval} is first applied
if the expression is a prvalue.
The result is a pointer to the first element of
the possibly-converted array glvalue.
Copy link
Contributor

Choose a reason for hiding this comment

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

glvalue is an expression, it doesn't have elements.

@languagelawyer
Copy link
Contributor

We have lots more places where we expect a prvalue, but currently don't say so.

Probably you remember, but just in case: this is http://wg21.link/CWG1642

and function-to-pointer\iref{conv.func} standard conversions are
performed on the second and third operands. After those conversions, one
of the following shall hold:
The resulting second and third operands are expected to be
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we say "possibly-converted" instead of "resulting"

array-to-pointer\iref{conv.array},
and function-to-pointer\iref{conv.func}
standard conversions are performed on the operands.
The operands are expected to be prvalues\iref{basic.lval}.
The comparison is deprecated if
Copy link
Contributor

Choose a reason for hiding this comment

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

Ending the previous sentence with a semicolon and continuing with "the comparison is deprecated if [...]" flows better.

The comparison is deprecated if
both operands were of array type
prior to these conversions\iref{depr.array.comp}.
an array-to-pointer\iref{conv.array} conversion
Copy link
Contributor

Choose a reason for hiding this comment

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

The array-to-pointer conversion is a single conversion -- I think "an" should be "the" here.

The comparison is deprecated if
both operands were of array type
prior to these conversions\iref{depr.array.comp}.
an array-to-pointer\iref{conv.array} conversion
Copy link
Contributor

Choose a reason for hiding this comment

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

The array-to-pointer conversion is a single conversion -- I think "an" should be "the" here.

@zygoloid zygoloid added this to the C++23 milestone Sep 18, 2020
@zygoloid zygoloid added the changes requested Changes to the wording or approach have been requested and not yet applied. label Oct 18, 2020
@wg21bot wg21bot added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Jun 15, 2021
@jensmaurer jensmaurer removed this from the C++23 milestone Oct 7, 2023
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

5 participants