https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100708
Bug ID: 100708 Summary: dynamic_cast can convert xvalue to lvalue Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rs2740 at gmail dot com Target Milestone: --- GCC accepts struct A { virtual ~A() {}; }; struct B : A {} b; void g () { dynamic_cast<B&>(static_cast<A&&>(b)); } [expr.dynamic.cast]/2 says that for dynamic_cast<T>(v): If T is an lvalue reference type, v shall be an lvalue of a complete class type, and the result is an lvalue of the type referred to by T.