[Bug c++/58487] Missed return value optimization

antoshkka at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jun 28 16:36:47 GMT 2021


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

Antony Polukhin <antoshkka at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |antoshkka at gmail dot com

--- Comment #3 from Antony Polukhin <antoshkka at gmail dot com> ---
Minimized example, move constructor should not be called:

struct A {
  A() = default;
  A(A&&);
};

A test() {
  if (true) {
    A a;
    return a;
  } else {
    return A{};
  }
}


Godbolt playground: https://godbolt.org/z/4Pzq83WWY


More information about the Gcc-bugs mailing list