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

    <tr>
        <th>Summary</th>
        <td>
            Confusing error when trying to move a type that isn't movable
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    The code
```c++
#include <iterator>
#include <memory>
#include <vector>

struct SomeDescription {
  unsigned size;
};

struct MOType {
  const SomeDescription description;

  MOType(const MOType &) = delete;

  MOType(MOType &&) = default;
  //MOType &operator=(MOType &&) = default;
};

void assignMovableContent(std::vector<MOType> &dynArray) {
  std::vector<MOType> other;
 other.assign(std::make_move_iterator(dynArray.begin()), std::make_move_iterator(dynArray.end()));
}

void test() {
 std::vector<MOType> sample;
 assignMovableContent(sample);
}
```

[fails with the error](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:2,endLineNumber:26,positionColumn:2,positionLineNumber:26,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:'%23include+%3Citerator%3E%0A%23include+%3Cmemory%3E%0A%23include+%3Cvector%3E%0A%0Astruct+SomeDescription+%7B%0A++unsigned+size%3B%0A%7D%3B%0A%0Astruct+MOType+%7B%0A++const+SomeDescription+description%3B%0A%0A++MOType(const+MOType+%26)+%3D+delete%3B%0A%0A++MOType(MOType+%26%26)+%3D+default%3B%0A++//MOType+%26operator%3D(MOType+%26%26)+%3D+default%3B%0A%7D%3B%0A%0Avoid+assignMovableContent(std::vector%3CMOType%3E+%26dynArray)+%7B%0A++std::vector%3CMOType%3E+other%3B%0A++other.assign(std::make_move_iterator(dynArray.begin()),+std::make_move_iterator(dynArray.end()))%3B%0A%7D%0A%0Avoid+test()+%7B%0A++std::vector%3CMOType%3E+sample%3B%0A++assignMovableContent(sample)%3B%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:38.86323952108572,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:clang1910,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-stdlib%3Dlibc%2B%2B+-std%3Dc%2B%2B23',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+19.1.0+(Editor+%231)',t:'0')),k:11.531674154618882,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+gcc+14.2',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+19.1.0+(Compiler+%231)',t:'0')),k:49.6050863242954,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)
```
In file included from <source>:2:
In file included from /opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/memory:944:
In file included from /opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/__memory/inout_ptr.h:16:
In file included from /opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/__memory/shared_ptr.h:31:
In file included from /opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/__memory/uninitialized_algorithms.h:13:
/opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/__algorithm/copy.h:40:17: error: object of type 'MOType' cannot be assigned because its copy assignment operator is implicitly deleted
   40 |       *__result = *__first;
 | ^
/opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/__algorithm/copy_move_common.h:95:19: note: in instantiation of function template specialization 'std::__copy_impl<std::_ClassicAlgPolicy>::operator()<std::move_iterator<std::__wrap_iter<MOType *>>, std::move_iterator<std::__wrap_iter<MOType *>>, MOType *>' requested here
   95 |   auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first));
      | ^
/opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/__algorithm/copy.h:109:15: note: in instantiation of function template specialization 'std::__copy_move_unwrap_iters<std::__copy_impl<std::_ClassicAlgPolicy>, std::move_iterator<std::__wrap_iter<MOType *>>, std::move_iterator<std::__wrap_iter<MOType *>>, MOType *, 0>' requested here
  109 |   return std::__copy_move_unwrap_iters<__copy_impl<_AlgPolicy> >(
      | ^
/opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/__algorithm/copy.h:116:15: note: in instantiation of function template specialization 'std::__copy<std::_ClassicAlgPolicy, std::move_iterator<std::__wrap_iter<MOType *>>, std::move_iterator<std::__wrap_iter<MOType *>>, MOType *>' requested here
 116 |   return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second;
      | ^
/opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/vector:1380:12: note: in instantiation of function template specialization 'std::copy<std::move_iterator<std::__wrap_iter<MOType *>>, MOType *>' requested here
 1380 |       std::copy(__first, __mid, this->__begin_);
      | ^
/opt/compiler-explorer/clang-19.1.0/bin/../include/c++/v1/vector:1369:3: note: in instantiation of function template specialization 'std::vector<MOType>::__assign_with_size<std::move_iterator<std::__wrap_iter<MOType *>>, std::move_iterator<std::__wrap_iter<MOType *>>>' requested here
 1369 |   __assign_with_size(__first, __last, std::distance(__first, __last));
 |   ^
<source>:20:9: note: in instantiation of function template specialization 'std::vector<MOType>::assign<std::move_iterator<std::__wrap_iter<MOType *>>, 0>' requested here
   20 | other.assign(std::make_move_iterator(dynArray.begin()), std::make_move_iterator(dynArray.end()));
      | ^
<source>:14:3: note: copy assignment operator is implicitly deleted because 'MOType' has a user-declared move constructor
   14 | MOType(MOType &&) = default;
      |   ^
1 error generated.
```

If you add a move assignment operator (that is never mentioned in diagnostics), clang recommends to delete it. Const-ness of the field 'description' is never mentioned as a problem.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWt-O4rjSfxr3jdUIOwkJF1wA3Ugrfbuz0ux3biMnKcC7js2xHXrYpz-ynYQEaKZn1NMzI8QQu_65qvyrstPMGL6TAAuUrFDy9MAau1d6cTTsYBh_KFR1Wvy1B1yqCtD0CU2XaDYNnxLRlfuEURpxWYqmAoyiNbegmVUaRc-3pmuolT69MnmEcsTpv43VTWnxZ1XDE5hS84PlSmKUtuoxbqRfSIUN_xdQ1JmVPp1_DyX9_umv0wGGAkolzbWG6vz7QhBuZSCaBdZOJJ0hOscoesIVCLDwOt-QY8C0ZY2wPRfGiG4Q3ZyJ1aHz7tNbhVz74ah4hUP0f1dHVghYK2lBWkQzYysULVG07GKxbk2Onp2e6iSXWrOTV3Z24D0uZfegz0vyj5OgfaivZv9AXqsj5H0G0axTNylgxx05onP_WeM3MoKsBmzzkVcuXWLB2EA8WNu9pRlWH8Q5yK_6NJDd1N7tqKExKFltGRcGv3C7x3YPGLRWGiUu5ntrD8ZZ5DNjp6pCCTtReucHop2fIn4Z2esPexQt3b5-rrh32Jr72WzLBUhWg39KCaIpouutkvZzydxKlyRuB_7fwJ9fAtk0kP3tphFdCyadrhLRxKGE_1obEFCGreT0gKzWSjS1e6SIrkFW_8cl_NHUhUuWpUvn9UEZ7lhGlN3gNXmv4rNl2vZM5GpqxOqnrxlu0bm8M6rRZeset7YOvjwgJgP4o0n0jGjiIO6aqkXBuzRtvg1pOghDdHUBVoEpXbWUDpw7VER05XGRJlE3naRPo8eB3A6grsR5oLupeIiTY6mBc4yVFzo8brVLfvLCPG7elXPJf0NIgMCBFF-uBmDacfeAGli_S_a1Ox2cILp6I8a6aHd6fbSD8gHW3ojH14UE4L3wwTvB79CAbwPgK7-NXXbG4O9acwe140V_FZcv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