[llvm-bugs] [Bug 30340] New: Poor diagnostics when an explicitly defaulted move assignment operator can't be generated

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 9 13:32:08 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30340

            Bug ID: 30340
           Summary: Poor diagnostics when an explicitly defaulted move
                    assignment operator can't be generated
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: john.firebaugh at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

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 (https://godbolt.org/g/yyhU39):

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 (https://godbolt.org/g/IVx9xU):

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160909/33904e82/attachment-0001.html>


More information about the llvm-bugs mailing list