<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59683>59683</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            class with rvalue reference in copy constructor fails to compile
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          yurivict
      </td>
    </tr>
</table>

<pre>
    This example fails:
```
#include <map>
#include <string>

class Options {

  class AttributeType : std::string {
  public:
 using Base = std::string;

    AttributeType(const AttributeType& other) = default;
    AttributeType(AttributeType&& other) : Base(other) {} // offender
  };

  std::map<std::string, AttributeType> attributes;

public:
  Options& operator=(const Options& other) {
    attributes = other.attributes;
  }
};

int main() {
 Options o1, o2;
        o1 = o2;
        return 0;
}
```

```
$ clang++-devel -std=c++20 o.cpp

o.cpp:20:3: warning: non-void function does not return a value [-Wreturn-type]
  }
  ^
In file included from o.cpp:2:
/usr/include/c++/v1/map:762:17: error: no viable overloaded '='
        __ref() = __v.__get_value();
        ~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/__tree:1662:39: note: in instantiation of member function 'std::__value_type<std::string, Options::AttributeType>::operator=' requested here
 __cache.__get()->__value_ = *__first;
 ^
/usr/include/c++/v1/__tree:1619:9: note: in instantiation of function template specialization 'std::__tree<std::__value_type<std::string, Options::AttributeType>, std::__map_value_compare<std::string, std::__value_type<std::string, Options::AttributeType>, std::less<std::string>, true>, std::allocator<std::__value_type<std::string, Options::AttributeType>>>::__assign_multi<std::__tree_const_iterator<std::__value_type<std::string, Options::AttributeType>, std::__tree_node<std::__value_type<std::string, Options::AttributeType>, void *> *, long>>' requested here
 __assign_multi(__t.begin(), __t.end());
 ^
/usr/include/c++/v1/map:1077:21: note: in instantiation of member function 'std::__tree<std::__value_type<std::string, Options::AttributeType>, std::__map_value_compare<std::string, std::__value_type<std::string, Options::AttributeType>, std::less<std::string>, true>, std::allocator<std::__value_type<std::string, Options::AttributeType>>>::operator=' requested here
            __tree_ = __m.__tree_;
                    ^
o.cpp:19:16: note: in instantiation of member function 'std::map<std::string, Options::AttributeType>::operator=' requested here
    attributes = other.attributes;
 ^
/usr/include/c++/v1/__utility/pair.h:262:11: note: candidate function not viable: no known conversion from 'const value_type' (aka 'const pair<const std::string, Options::AttributeType>') to 'const typename conditional<is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value, pair<string &, AttributeType &>, __nat>::type' (aka 'const std::__nat') for 1st argument
    pair& operator=(typename conditional<
 ^
/usr/include/c++/v1/__utility/pair.h:275:11: note: candidate function not viable: no known conversion from 'const value_type' (aka 'const pair<const std::string, Options::AttributeType>') to 'typename conditional<is_move_assignable<first_type>::value && is_move_assignable<second_type>::value, pair<string &, AttributeType &>, __nat>::type' (aka 'std::__nat') for 1st argument
    pair& operator=(typename conditional<
 ^
/usr/include/c++/v1/__utility/pair.h:291:11: note: candidate template ignored: requirement '_CheckTLC<const pair<const string, AttributeType> &>::__enable_assign()' was not satisfied [with _Tuple = const value_type &]
    pair& operator=(_Tuple&& __p) {
 ^
/usr/include/c++/v1/__utility/pair.h:40:29: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'const pair<const key_type, mapped_type>' to 'const pair<std::string &, Options::AttributeType &>' for 1st argument
struct _LIBCPP_TEMPLATE_VIS pair
                            ^
1 warning and 1 error generated.
```

clang-16.0.0
FreeBSD 13.1
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWN2O4rgSfhpzY4GI02C44IKfRhppjs5I0zrn0jJJBbzt2Fnbobf3Yp99ZTsJEGBmeqdnpJE2Qk3j2PXz1Vflsrm1Yq8AFmiyQpPNgNfuoM3itTbiKDI32On8dfF0EBbDH7ysJOCCC2lRukTjDRov0XTcfOJPkgqVyToHjNJ1ySuUPt56Y50Ran96Gf5mkluL_1s5oZXFiK7OX2IcXy-dM2JXO3h6rbyoJb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