-
Notifications
You must be signed in to change notification settings - Fork 774
[expr.const] Check the result object of a prvalue #6267
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.const] Check the result object of a prvalue #6267
Conversation
A prvalue may not have a result object, at least in the scalar case. |
Although temporary materialization doesn't happen in some cases, I think it's harmless to require the result object for the purpose of checking whether the prvalue is a constant expression. |
1bdc388
to
7eb1d52
Compare
This comment was marked as outdated.
This comment was marked as outdated.
7eb1d52
to
95981de
Compare
This comment was marked as outdated.
This comment was marked as outdated.
95981de
to
bd7b1ff
Compare
Rebased and force-pushed. @jensmaurer @tkoeppe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is an improvement.
I disagree. Here, for example, we surely want consteval int f() { return 42; };
int x = f() + 1; The existing wording isn't correct but this change takes it further in the wrong direction. |
Ok. Maybe just "result"? |
What's the harm if we require a result object for the determination? Did you mean that if we can't even say "a prvalue whose result object..." without actual temporary materialization? But IIUC in the scalar case, addtional temporary materialization shoudn't be observable. |
"Result" is synonymous with "value" here, so I don't think that would be an improvement over the current wording.
If we want to avoid making drastic changes to the structure of the wording here, then I think having to go from 'value' to 'object' in some way or another is unavoidable (sadly), because we don't have a good framework for talking about values (not objects) of class and array types. Perhaps phrasing the requirements in terms of the constituent values/references of "a hypothetical object initialized from the prvalue" (or something along those lines) could work? (Then there's also the fact that this paragraph doesn't handle prvalues of type |
This is exactly what I'm meaning with "a prvalue whose result object...". Did you mean that we can't just say that if prvalue materialization doesn't happen?
IIUC this is not an issue. The Edit: Oops, it seems that P2686R4 accidently made |
@jensmaurer Assuming this is still good. Let's merge after motions. |
Fixes #5422.
The remain issue (modulo CWG2558) is that we shouldn't imply a prvalue is an object, which is not true since C++17.