https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82113
Bug ID: 82113 Summary: RVO isn't applied to base class constructor call in C++17 Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: for.gcc.bugzilla at gmail dot com Target Milestone: --- Reported on https://stackoverflow.com/questions/46065704/why-isnt-rvo-applied-to-base-class-constructor-call-in-c17 With C++17 guaranteed copy elision, B::B() below should compile even when Base::Base(Base&&) is deleted. struct Base { Base(Base&&) = delete; Base& operator=(Base&&) = delete; Base() { } }; Base make_base() { return Base{}; } struct A { A() : b(make_base()) {} // <<<--- compiles fine Base b; }; #ifdef FAIL struct B : public Base { B() : Base(make_base()) {} // <<<--- "Base(Base&&) is deleted" }; #endif example https://godbolt.org/g/w3jRuc