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

            Bug ID: 67302
           Summary: copy elision in return (expression)
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: osensei80 at gmail dot com
  Target Milestone: ---

Consider:

struct A
{
  A() { std::cout << "default ctor\n"; }
  A(const A&) { std::cout << "copy ctor\n"; }
  A(A&&) { std::cout << "move ctor\n"; }
};

A bar()
{
  A a;
  return( a );
}

int main()
{
  bar();
}

Compiling with option -std=c++11 the output is "default ctor". But compiling
with -std=c++14 or -std=c++1z the output is

default ctor
move ctor

Why get's the move not elided?

Reply via email to