type = cv_unqualified (type);
/* [expr.reinterpret.cast]
- A glvalue expression of type T1 can be cast to the type
+ A glvalue of type T1, designating an object x, can be cast to the type
"reference to T2" if an expression of type "pointer to T1" can be
- explicitly converted to the type "pointer to T2" using a
- reinterpret_cast. */
+ explicitly converted to the type "pointer to T2" using a reinterpret_cast.
+ The result is that of *reinterpret_cast<T2 *>(p) where p is a pointer to x
+ of type "pointer to T1". No temporary is created, no copy is made, and no
+ constructors (11.4.4) or conversion functions (11.4.7) are called. */
if (TYPE_REF_P (type))
{
- if (TYPE_REF_IS_RVALUE (type) && !VOID_TYPE_P (intype))
- {
- if (!obvalue_p (expr))
- /* Perform the temporary materialization conversion. */
- expr = get_target_expr_sfinae (expr, complain);
- }
- else if (!lvalue_p (expr))
+ if (!glvalue_p (expr))
{
if (complain & tf_error)
- error_at (loc, "invalid cast of an rvalue expression of type "
+ error_at (loc, "invalid cast of a prvalue expression of type "
"%qT to type %qT",
intype, type);
return error_mark_node;
struct B : A {};
auto && a = static_cast<A&&>(B());
-auto && b = reinterpret_cast<A&&>(B());
+auto && b = reinterpret_cast<A&&>(B()); // { dg-error "prvalue" }
auto && c = dynamic_cast<A&&>(B());
auto && d = dynamic_cast<B&&>(static_cast<A&&>(B()));
auto && e = const_cast<B&&>(B());