Open
Description
Hi,
Consider this example code:
struct Base
{};
int foo(Base&);
struct Derived : Base
{
auto f() & -> decltype(foo(static_cast<Base&>(*this)))
{
return foo(static_cast<Base&>(*this));
}
};
Clang emits this failure:
<source>:9:32: error: non-const lvalue reference to type 'Base' cannot bind to a value of unrelated type 'Derived'
9 | auto f() & -> decltype(foo(static_cast<Base&>(*this)))
|
However, GCC, MSVC and EDG accept the code. I am confused as to why Clang complains; a Derived class should be possible to upcast to its base?
Thanks!