-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compiler on this issueDoes the clang frontend diverge from edg compiler on this issuediverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueDoes the clang frontend diverge from msvc on this issuerejects-valid
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!
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compiler on this issueDoes the clang frontend diverge from edg compiler on this issuediverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueDoes the clang frontend diverge from msvc on this issuerejects-valid