http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57998

            Bug ID: 57998
           Summary: Unhelpful error message when a class has no move
                    constructor
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luto at mit dot edu

When trying and failing to move an object because the move constructor is
deleted, the error message tells you so.  When there is no move constructor at
all, however, the error message is unhelpful.  For example, this:

#include <utility>

struct move_only
{
  move_only() = default;
  move_only(move_only&&) = default;
  move_only &operator = (move_only&&) = default;
};

struct broken : move_only
{
  move_only mo;
  ~broken() {}
};

void test()
{
  broken a;
  broken b(std::move(a));
}

is correctly rejected with this error:

move_base.cc: In function ‘void test()’:
move_base.cc:19:24: error: use of deleted function ‘broken::broken(const
broken&)’
   broken b(std::move(a));
                        ^
move_base.cc:10:8: note: ‘broken::broken(const broken&)’ is implicitly deleted
because the default definition would be ill-formed:
 struct broken : move_only
        ^
move_base.cc:10:8: error: use of deleted function ‘constexpr
move_only::move_only(const move_only&)’
move_base.cc:3:8: note: ‘constexpr move_only::move_only(const move_only&)’ is
implicitly declared as deleted because ‘move_only’ declares a move constructor
or move assignment operator
 struct move_only
        ^
move_base.cc:10:8: error: use of deleted function ‘constexpr
move_only::move_only(const move_only&)’
 struct broken : move_only
        ^

It would be much more helpful if there was another line saying something like
"broken::broken(broken&&) is suppressed because broken has a user-defined
destructor".

Reply via email to