c++: reinterpret_cast from prvalue to rvalue ref [PR98440]
authorJason Merrill <jason@redhat.com>
Mon, 5 Apr 2021 19:50:48 +0000 (15:50 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 5 Apr 2021 21:27:00 +0000 (17:27 -0400)
commit07f56824fd4da14a48030e698c8eb58de951c741
tree250ead25b891f8a61b1f898b7d0f32d2f9c09555
parent9f4c41147a41d08a74990eafe69a1064a3c13435
c++: reinterpret_cast from prvalue to rvalue ref [PR98440]

In r260622 I allowed this under the general principle that [basic.lval]
"Whenever a prvalue appears as an operand of an operator that expects a
glvalue for that operand, the temporary materialization conversion (7.3.4)
is applied to convert the expression to an xvalue."  But
[expr.reinterpret.cast] specifically excludes creating a temporary in this
case.

gcc/cp/ChangeLog:

PR c++/98440
* typeck.c (build_reinterpret_cast_1): Don't perform
temporary materialization.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/rv-cast6.C: Expect reinterpret_cast error.
* g++.dg/cpp0x/reinterpret_cast2.C: Adjust message.
* g++.old-deja/g++.jason/rvalue3.C: Likewise.
gcc/cp/typeck.c
gcc/testsuite/g++.dg/cpp0x/reinterpret_cast2.C
gcc/testsuite/g++.dg/cpp0x/rv-cast6.C
gcc/testsuite/g++.old-deja/g++.jason/rvalue3.C