-
Notifications
You must be signed in to change notification settings - Fork 7
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
CWG2981 [expr.arith.conv] 0 < 0
is an int
#663
Comments
I'm not really sure what the intended wording strategy here is. https://eel.is/c++draft/expr.mul chooses to say that:
But why wouldn't the usual arithmetic conversions determine the result by default? [expr.arith.conv] simply states what the result is, and that wording isn't conditional on "if stated to determine the type of the result". Also note that [expr.add] relies on the type of In short, we end up with three cases at least:
On another side note, I couldn't find any wording which states what the value category of My preferred overarching fix would be to purge the practice of using [expr.arith.conv] to determine the result type completely (it's weird, done inconsistently, and doesn't save that much wording elsewhere anyway), and that could be done as an editorial fix once normative wording problems are fixed. |
I think we should limit "usual arithmetic conversions" to exactly that: conversions on the operands. The result type (and value category) should be specified by each individual operator. |
You know what, I think I'll just make a paper for that. |
Why a paper? I certainly want a bit of CWG review on the change, but this feels entirely like a core issue. |
Because the blast radius is pretty large here, and I think as a drive-by fix, we should also specify the value category where needed. I'll look into how big of a change that really is first. I guess I can post the diff here and see if that needs a paper. In the end, we should clearly state that e.g. |
9 places (max) need updates. |
Suggested resolution v2Update [expr.arith.conv] paragraph 1 as follows:
Editor's note: While it's not incorrect that result types are also often yielded in a similar way, it's not always the case (e.g. [expr.rel], [expr.eq]), and we should purge any mention of result types if these conversions aren't stated to determine the result anyway. Update [expr.mul] paragraph 2 as follows:
Update [expr.add] paragraph 1 as follows:
Update [expr.rel] paragraph 2 as follows:
Editor's note: Since we state that Update [expr.eq] paragraph 7 as follows:
Update [expr.bit.and] paragraph 1 as follows:
Update [expr.xor] paragraph 1 as follows:
Update [expr.bit.or] paragraph 1 as follows:
|
CWG2981 with suggested resolution adjusted to be consistent with [expr.cond] p7.2 |
0 < 0
is an int
0 < 0
is an int
Reference (section label): [expr.arith.conv] pargraph 1
Issue description
[expr.rel] paragraph 2 states that the result of the relational operator for e.g.
0 < 0
isbool
. This is subsequently contradicted by [expr.rel] paragraph 3, which states that the usual arithmetic conversions are applied, and [expr.arith.conv] paragraph 1 states:If paragraph 3 supersedes paragraph 2, then
0 < 0
is of typeint
.Suggested resolution
Update [expr.arith.conv] paragraph 1 as follows:
The text was updated successfully, but these errors were encountered: