-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Full name of submitter (unless configured in github; will be published with the issue): Lénárd Szolnoki
Reference (section label): [expr.const]
Issue description: prvalue void core constant expressions should be constant expressions
A constant expression is either:
- a glvalue core constant expression E for which
...- a prvalue core constant expression whose result object ([basic.lval]) satisfies the following constraints
...
A prvalue core constant expression of type void has no result object, therefore it's missing from the list. My reading is that such core constant expressions are not constant expressions.
Therefore the following program is ill-formed:
consteval void foo() {}
int main() {
foo(); // immediate invocation must produce a constant expression
}GCC, clang and MSVC accept this program (https://godbolt.org/z/Tfjeh3eTo).
In addition, the expression corresponding to a consteval-block-declaration is also a prvalue expression of type void, which "shall be a constant expression" [dcl.pre].
Suggested resolution:
Add the following point under "A constant expression is either:"
- a prvalue core constant expression of type
void.