Full name of submitter (unless configured in github; will be published with the issue): Hubert Tong
Reference (section label): expr.cast
Link to reflector thread (if any): N/A
Issue description:
In https://eel.is/c++draft/expr.cast#4, we say:
If a conversion can be interpreted in more than one way as a static_cast followed by a const_cast, the conversion is ill-formed.
In the following, we see that the choice of static_cast can differ between casting to an lvalue reference type or an rvalue reference type.
struct A {};
struct B : A {};
const B b;
void f() {
(A &&)b; // ill-formed?
const_cast<A &&>(static_cast<const A &>(b));
const_cast<A &&>(static_cast<const volatile A &&>(b));
}
Suggested resolution:
If a conversion can be interpreted in more than one way as a static_cast, not arbitrarily adding cv-qualification and to an rvalue reference type if and only if converting to an rvalue reference type, followed by a const_cast, the conversion is ill-formed.
Full name of submitter (unless configured in github; will be published with the issue): Hubert Tong
Reference (section label): expr.cast
Link to reflector thread (if any): N/A
Issue description:
In https://eel.is/c++draft/expr.cast#4, we say:
In the following, we see that the choice of
static_castcan differ between casting to an lvalue reference type or an rvalue reference type.Suggested resolution:
If a conversion can be interpreted in more than one way as a static_cast, not arbitrarily adding cv-qualification and to an rvalue reference type if and only if converting to an rvalue reference type, followed by a const_cast, the conversion is ill-formed.