| Issue |
114024
|
| Summary |
[clang] Failure when upcasting to a base class in trailing return type _expression_
|
| Labels |
clang:frontend,
rejects-valid
|
| Assignees |
|
| Reporter |
carlosgalvezp
|
Hi,
Consider this example code:
```cpp
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:
```console
<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)))
|
```
[Repro](https://godbolt.org/z/nns6EKhzM).
However, GCC accepts the code. I am confused as to why Clang complains; a Derived class should be possible to upcast to its base?
Thanks!
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs