Hi! The if (TYPE_REF_IS_RVALUE (type)) code has been added recently, but build_target_expr_with_type asserts that the expression doesn't have void type. Fixed by using the old handling in that case (the expression is not lvalue in that case and diagnostics is emitted if complain).
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-02-18 Jakub Jelinek <ja...@redhat.com> PR c++/89391 * typeck.c (build_reinterpret_cast_1): Don't handle void to && conversion go through build_target_expr_with_type. * g++.dg/cpp0x/reinterpret_cast2.C: New test. --- gcc/cp/typeck.c.jj 2019-01-30 08:35:46.990055278 +0100 +++ gcc/cp/typeck.c 2019-02-18 21:19:09.727590300 +0100 @@ -7477,7 +7477,7 @@ build_reinterpret_cast_1 (tree type, tre reinterpret_cast. */ if (TYPE_REF_P (type)) { - if (TYPE_REF_IS_RVALUE (type)) + if (TYPE_REF_IS_RVALUE (type) && !VOID_TYPE_P (intype)) { if (!obvalue_p (expr)) /* Perform the temporary materialization conversion. */ --- gcc/testsuite/g++.dg/cpp0x/reinterpret_cast2.C.jj 2019-02-18 21:27:24.844391776 +0100 +++ gcc/testsuite/g++.dg/cpp0x/reinterpret_cast2.C 2019-02-18 21:27:05.261723238 +0100 @@ -0,0 +1,10 @@ +// PR c++/89391 +// { dg-do compile { target c++11 } } + +struct S { }; + +void +foo () +{ + auto a = reinterpret_cast<S&&>(foo ()); // { dg-error "invalid cast of an rvalue expression of type 'void' to type" } +} Jakub