Skip to content

[expr.const] P2686R4 made it less clear that a prvalue constant expression must have an object type #7551

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
frederick-vs-ja opened this issue Jan 9, 2025 · 2 comments

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?

@frederick-vs-ja
Copy link
Contributor Author

In which case would a non-object constant expression be acceptable / required to start with?

I don't think there's any such context currently. So, is it OK to accidentally change whether a void value is a constant expression since the actual requirements won't change?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants