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] P2686R4 made it less clear that a prvalue constant expression must have an object type #7551

Open
frederick-vs-ja opened this issue Jan 9, 2025 · 1 comment

Comments

@frederick-vs-ja
Copy link
Contributor

In C++23, it seemed clear to me that a prvalue constant expression was required to have an object type, because N4950 [expr.const] p13 explicitly listed permitted cases for various object types.

However, after P2686R4, [expr.const] p22 doesn't seem to require object types, and void expressions are arguably accepted. At least, a prvalue of an empty class type and a void prvalue don't seem distinguishable.

Should we clarify the wording to say a prvalue constant expression must have an object type, or, conversely, a void expression can be a prvalue constant expression?

@jensmaurer
Copy link
Member

A "constant expression" is a semantic requirement of the environment where it appears, e.g. in an array bound or similar. In which case would a non-object constant expression be acceptable / required to start with?

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