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.const] Check the result object of a prvalue #6267

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frederick-vs-ja
Copy link
Contributor

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.

@lprv
Copy link
Contributor

lprv commented Jun 5, 2023

A prvalue may not have a result object, at least in the scalar case.

@frederick-vs-ja
Copy link
Contributor Author

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.

@wg21bot wg21bot added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Apr 19, 2024
@frederick-vs-ja frederick-vs-ja force-pushed the constant-result-object branch from 1bdc388 to 7eb1d52 Compare April 23, 2024 02:07
@frederick-vs-ja

This comment was marked as outdated.

@frederick-vs-ja

This comment was marked as outdated.

@tkoeppe tkoeppe removed the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Oct 17, 2024
@wg21bot wg21bot added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Dec 19, 2024
@frederick-vs-ja
Copy link
Contributor Author

Rebased and force-pushed. @jensmaurer @tkoeppe

Copy link
Member

@jensmaurer jensmaurer left a 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.

@jensmaurer jensmaurer removed the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Dec 30, 2024
@lprv
Copy link
Contributor

lprv commented Dec 30, 2024

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.

I disagree.

Here, for example, we surely want f() to be a constant expression, but it does not have a result object:

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.

@jensmaurer
Copy link
Member

Ok. Maybe just "result"?

@jensmaurer jensmaurer self-requested a review December 30, 2024 15:31
@frederick-vs-ja
Copy link
Contributor Author

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.

I disagree.

Here, for example, we surely want f() to be a constant expression, but it does not have a result object:

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.

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.

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

Successfully merging this pull request may close these issues.

[dcl.constexpr] Uninitialized non-static data members of fundamental type CWG2558
5 participants