https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87530
Bug ID: 87530 Summary: copy elision in return statement doesn't check for rvalue reference to object type Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Example from StackOverflow (https://stackoverflow.com/q/52662407/2069064): struct Base { }; template<typename T> struct A : Base { A(); A(Base&&); }; A<int> foo() { A<double> v; return v; } gcc accepts this code, invoking the A(Base&&) constructor in the return statement. But the requirement in [class.copy.elision]/3 requires the first type in the selected constructor to be an rvalue reference to the object's type, which it is not.