Commit 596334fa by Jason Merrill

PR c++/93257 - consteval void function.

A prvalue can have void type, and if it doesn't do anything prohibited in a
constant expression, it's vacuously constant.

	* constexpr.c (verify_constant): Allow void_node.
parent 7192b1ec
2020-01-15 Jason Merrill <jason@redhat.com>
PR c++/93257 - consteval void function.
* constexpr.c (verify_constant): Allow void_node.
PR c++/92871 - bad code with xvalue and GNU ?: extension.
* call.c (prevent_lifetime_extension): New.
(build_conditional_expr_1): Use it.
......
......@@ -2609,7 +2609,8 @@ static bool
verify_constant (tree t, bool allow_non_constant, bool *non_constant_p,
bool *overflow_p)
{
if (!*non_constant_p && !reduced_constant_expression_p (t))
if (!*non_constant_p && !reduced_constant_expression_p (t)
&& t != void_node)
{
if (!allow_non_constant)
error ("%q+E is not a constant expression", t);
......
// PR c++/93257
// { dg-do compile { target c++2a } }
template <bool, typename>
consteval void test() {}
int main() {
test<false, int>();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment