https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93106

            Bug ID: 93106
           Summary: [c++2a] Deleted move constructor is not selected when
                    returning an automatic variable
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ph3rin at gmail dot com
  Target Milestone: ---

According to the c++ standard (draft n4835) the following code should not
compile because it references a deleted function:

struct not_movable {
    not_movable() = default;
    not_movable(not_movable const&) = default;
    not_movable(not_movable&&) = delete;
};

not_movable foo() {
    not_movable obj;
    return obj;
}

When returning obj, the overload resolution should successfully select the
deleted move constructor, therefore resulting in a compiler error.

The code has been tested under gcc 9.2 with compiler flags -std=c++2a.

Quotes from the standard: http://eel.is/c++draft/class.copy.elision#3

Reply via email to