The following code is rejected by both Clang and GCC (trunk versions):
#include
struct Base
{
Base() = default;
Base(Base const&
[class.copy]/32 continues:
[...] if the type of the first parameter of the selected constructor is not an rvalue reference to the object's type (possibly cv-qualified), overload resolution is performed again, considering the object as an lvalue.
The first overload resolution, treating d
as an rvalue, selects Base::Base(Base&&)
. The type of the first parameter of the selected constructor is, however, not Derived&&
but Base&&
, so the result of that overload resolution is discarded and you perform overload resolution again, treating d
as an lvalue. That second overload resolution selects the deleted copy constructor.