https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93257
Bug ID: 93257
Summary: consteval functions returning 'void' are rejected when
called
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: alisdairm at me dot com
Target Milestone: ---
The following simple program is accepted by Clang (trunk) and rejected by
current gcc (trunk) at the time of filing:
template <bool, typename>
consteval void test() {}
int main() {
test<false, int>();
return 0;
}
This gives the confusing error:
<source>: In function 'int main()':
<source>:5:22: error: '(void)0' is not a constant expression
5 | test<false, int>();
Not sure where the void cast of a 0 literal enters the picture, nor why it
would not be a constant expression.
Handy link to running the test on compiler explorer (where Clang results can be
confirmed):
https://godbolt.org/z/_AaBvh