https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70983
Bug ID: 70983 Summary: False ambiguity on member function rvalue overload using auto Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jackweston at live dot co.uk Target Milestone: --- In the following code, the call to Foo::GetString() works fine but the call to Foo::GetStringAuto() is reported as ambiguous and fails to compile. The auto should be deduced as `std::string` in both cases and the two situations should be identical (and unambiguous). -------------- #include <string> class Foo { public: Foo(std::string string) : m_string(std::move(string)) {} std::string & GetString() & { return m_string; } std::string && GetString() && { return std::move(m_string); } auto & GetStringAuto() & { return m_string; } auto && GetStringAuto() && { return std::move(m_string); } private: std::string m_string; }; int main() { Foo foo("blah"); std::string fooStringA = foo.GetString(); // works std::string fooStringB = foo.GetStringAuto(); // call is ambiguous return 0; }