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.unary.noexcept] Replace informative wording #6539

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Eisenwave
Copy link
Contributor

@Eisenwave Eisenwave commented Aug 30, 2023

Context and Problem with the Current Wording

I was briefly under the impression that a + b can throw for two ints a and b, because signed integer overflow is UB, and UB can result in throwing exceptions, and maybe the noexcept operator needs to consider that.

Paragraph 1 in its current form says:

determines whether the evaluation of its operand [...] can throw an exception

An unsuspecting reader like me might assume that this includes exceptions thrown as the result of UB. However, this isn't actually possible, and this wording is purely informative. Paragraph 3 contains the actual normative wording, explaining that the noexcept operator checks whether an expression is potentially-throwing.

Suggested Solution

This PR moves the actual normative wording from p3 up into p1 to avoid any future confusion. The informative wording is removed.

Comment on lines 5045 to 5046
The \keyword{noexcept} operator yields \keyword{true}
unless the full-expression of the operand
is potentially-throwing\iref{except.spec}.
The operand of the \keyword{noexcept} operator
is an unevaluated operand\iref{term.unevaluated.operand}.
\begin{bnf}
Copy link
Member

Choose a reason for hiding this comment

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

I think there is some room for improvement in this subclause, but talking about "the operand" in detail before we've even introduced the grammar seems unhelpful.

My suggestion:

  • grammar first
  • then talk about the operand
  • then talk about the result
  • then have the note about constant expression

Copy link
Contributor Author

@Eisenwave Eisenwave Aug 31, 2023

Choose a reason for hiding this comment

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

I've implemented most of what you've suggested, but I don't understand what you mean by "note about constant expression". Neither the old wording nor the new wording talks about constant expressions.

Wouldn't adding a note be a topic for another PR?

Copy link
Member

Choose a reason for hiding this comment

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

"[Note 1 : A noexcept-expression is an integral constant expression (7.7). — end note]"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I wasn't looking at the second paragraph. I've moved it up now.

@Eisenwave
Copy link
Contributor Author

image
updated version

@jensmaurer
Copy link
Member

Sorry, but that's not exactly what I had in mind. Since the change is a little larger, I've created CWG2792 to have CWG review the change. See there for my suggestion; feel free to continue to discuss here.

@jensmaurer jensmaurer added the cwg Issue must be reviewed by CWG. label Sep 2, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants