<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Poor diagnostics when an explicitly defaulted move assignment operator can't be generated"
href="https://llvm.org/bugs/show_bug.cgi?id=30340">30340</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Poor diagnostics when an explicitly defaulted move assignment operator can't be generated
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>john.firebaugh@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Test case:
#include <utility>
struct Immovable {
Immovable& operator=(Immovable&&) = delete;
};
struct Foo {
Foo();
Foo& operator=(Foo&&) = default;
Immovable immovable;
};
int main() {
Foo foo1;
Foo foo2;
foo1 = std::move(foo2);
}
Clang output (<a href="https://godbolt.org/g/yyhU39">https://godbolt.org/g/yyhU39</a>):
16 : error: object of type 'Foo' cannot be assigned because its copy assignment
operator is implicitly deleted
foo1 = std::move(foo2);
^
9 : note: copy assignment operator is implicitly deleted because 'Foo' has a
user-declared move assignment operator
Foo& operator=(Foo&&) = default;
This error message gives no hint as to the actual issue, the fact that the
explicitly defaulted move assignment operator for Foo could not be generated.
Compare GCC's output (<a href="https://godbolt.org/g/IVx9xU">https://godbolt.org/g/IVx9xU</a>):
16 : error: use of deleted function 'Foo& Foo::operator=(Foo&&)'
foo1 = std::move(foo2);
^
9 : note: 'Foo& Foo::operator=(Foo&&)' is implicitly deleted because the
default definition would be ill-formed:
Foo& operator=(Foo&&) = default;
^~~~~~~~
9 : error: use of deleted function 'Immovable&
Immovable::operator=(Immovable&&)'
4 : note: declared here
Immovable& operator=(Immovable&&) = delete;
^~~~~~~~
Compilation failed</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>