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

[over.oper.general] p7 Precedence is not a formal wording nor specified #5475

Open
xmh0511 opened this issue May 19, 2022 · 2 comments
Open

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented May 19, 2022

[over.oper.general] p7 says

It is not possible to change the precedence, grouping, or number of operands of operators.

The "precedence" is not directly specified in this document, it is implied by the syntaxes of the grammar of expressions. [expr.footnote] p42 says

The precedence of operators is not directly specified, but it can be derived from the syntax.

It is plausible to use syntax in this wording to imply the precedence is not changed.

It is not possible to change the syntax, grouping, or number of operands of operators.

A + B * C;

Assume that A, B, and C are of class types. The expression is interpreted as additive-expression + multiplicative-expression rather than additive-expression * id-expression.

@jensmaurer
Copy link
Member

While I agree that the description of operator overloading should be better integrated into [expr], I disagree that the change "precedence" -> "syntax" is helpful here. The sentence you quote is essentially a note (nothing normative would change if it were omitted), and "precedence" is a lot more specific (and thus easier to understand) than "syntax".

@xmh0511
Copy link
Contributor Author

xmh0511 commented May 19, 2022

While I agree that the description of operator overloading should be better integrated into [expr]

Yes, this is the subject of #3957 and #5315. The relevant issues that can be fixed by the integration might be #5172, #5401, #5208. Integrate [over.oper] into [expr] would make [expr] self-consistent; any operation that forms an expression should be covered by [expr] regardless of what type of the operand is. [over] should only concern the resolution/selection between two functions. If we integrated [over.oper] into [expr.compound], the quoted rule could be changed as a note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants