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.ass] CWG 2399: What's "the expression"? #720

Closed
timsong-cpp opened this issue May 5, 2016 · 10 comments
Closed

[expr.ass] CWG 2399: What's "the expression"? #720

timsong-cpp opened this issue May 5, 2016 · 10 comments
Labels
cwg Issue must be reviewed by CWG.

Comments

@timsong-cpp
Copy link
Contributor

[expr.ass]/2,3,6 contains several references to "the expression":

-2- In simple assignment (=), the value of the expression replaces that of the object referred to by the left operand.

-3- If the left operand is not of class type, the expression is implicitly converted (Clause [conv]) to the cv-unqualified type of the left operand.

-6- When the left operand of an assignment operator is a bit-field that cannot represent the value of the expression, the resulting value of the bit-field is implementation-defined.

Clearly it's meant to refer to the right operand, i.e., the initializer-clause, but that's not necessarily an expression, and in any event the reference is unclear just reading the text.

@tkoeppe
Copy link
Contributor

tkoeppe commented May 10, 2016

Are you sure? Doesn't it refer to the assignment expression as a whole? The expression f() = 5 has value 5, and that value replaces the value of the left operand.

@timsong-cpp
Copy link
Contributor Author

The assignment expression as a whole is an lvalue referring to the left operand.

@burblebee
Copy link
Contributor

This sounds like a core issue. How does one turn an edit issue into a core issue?

@burblebee burblebee added the cwg Issue must be reviewed by CWG. label Jun 22, 2016
@tkoeppe
Copy link
Contributor

tkoeppe commented Jun 22, 2016

@burblebee: I think you wait until a friendly person (hello @zygoloid) emails the issue to the Core chair... :-)

jensmaurer added a commit to jensmaurer/draft that referenced this issue Dec 8, 2016
@jensmaurer jensmaurer self-assigned this Dec 8, 2016
@jensmaurer
Copy link
Member

We had a couple of instances already where the introduction of brace-init-lists in various contexts technically invalidated descriptions talking about "expressions". It seems very obvious what is meant here (= "right operand"), so I believe this could be handled editorially.

For @zygoloid to decide, of course.

@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 9, 2016

The current proposed solution doesn't work, because a braced-init-list does not have a value. So the description needs to distinguish between operands that have a value, and those that are described by p9.

From a discussion with @zygoloid:

  1. change p2 to say

In a simple assignment (=) whose right operand is an assignment-expression, the value of the that expression [...]"

  1. then p9 would define what happens in the other case in terms of the p2 or p4 wording
  2. maybe moving the assignment-expression / braced-init-list dispatch up front might be cleaner
  3. also, talking about what happens for class types here is unnecessary; none of the other overloadable operators bother with that, and the [expr] frontmatter covers it already.

@jensmaurer
Copy link
Member

Posted to the core reflector so that we get a core issue: http://lists.isocpp.org/core/2016/12/1382.php

@jensmaurer
Copy link
Member

See also CWG 1542.

@jensmaurer
Copy link
Member

Handled by CWG 2399.

@jensmaurer jensmaurer changed the title [expr.ass] What's "the expression"? [expr.ass] CWG 2399: What's "the expression"? Feb 24, 2019
@jensmaurer
Copy link
Member

Fixed by 9700b13 (Nov 2019).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG.
Projects
None yet
Development

No branches or pull requests

4 participants