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

[dcl.attr.assume] Contradictory wording around contextual conversion #6512

Closed
Eisenwave opened this issue Aug 25, 2023 · 3 comments
Closed

Comments

@Eisenwave
Copy link
Contributor

Eisenwave commented Aug 25, 2023

[dcl.attr.assume] says:

The expression is contextually converted to bool. The expression is not evaluated. If the converted expression would evaluate to true at the point where the assumption appears, the assumption has no effect.
Otherwise, the behavior is undefined.

This wording is mildly contradictory because the first sentence says that contextual conversion takes place. This might even invoke user-defined conversion operators, so the reader should assume that something is being evaluated here.

However, this is then contradicted by saying that the expression is not evaluated. If it's not evaluated, then obviously contextual conversion can't take place.

I think it would be much clearer to write:

-The expression is contextually converted to bool.
+The expression shall be contextually convertible to bool.
 The expression is not evaluated.
 If the converted expression would evaluate to true at the point where the assumption appears,
 the assumption has no effect.
 Otherwise, the behavior is undefined.

I am not sure if this issue is so severe that it's non-editorial.

@Eisenwave
Copy link
Contributor Author

Hmm, I think it might really be non-editorial, because the wording only says that the expression is not evaluated, but it does not say that the contextual conversion is not evaluated.

This is obviously unimplementable, because an implementation can't contextually convert the result of an expression that doesn't exist, because the expression has never been evaluated.

@Eisenwave
Copy link
Contributor Author

Eisenwave commented Aug 25, 2023

Or maybe I'm misunderstanding things. https://eel.is/c++draft/conv#def:contextually_implicitly_converted The way that contextual conversion is worded, it doesn't imply evaluation in itself.

@jensmaurer
Copy link
Member

The talk about conversions here is just about creating the syntax tree (with some implicit nodes). Whether that syntax tree is evaluated, is a second consideration.

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