https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96647
Bug ID: 96647 Summary: Can't resolve pointer to overloaded member with auto return type Product: gcc Version: 10.2.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rustamabd at gmail dot com Target Milestone: --- auto return type in combination with overloading and CRTP results in an overload set that cannot be disambiguated. Example: template<typename T> struct Base { auto f(int) { return static_cast<T*>(this); } auto f(char) { return static_cast<T*>(this); } }; struct A : Base<A> {}; int main() { A instance; // instance.f('x') // "fixes" the issue auto ptr = static_cast<A* (A::*)(char)>(&A::f); // error here (instance.*ptr)('x'); } Error: error: no matches converting function 'f' to type 'struct A* (struct A::*)(char)' 14 | auto ptr = static_cast<A* (A::*)(char)>(&A::f); // error here | ^ note: candidates are: 'auto Base<T>::f(char) [with T = A]' 4 | auto f(char) { return static_cast<T*>(this); } | ^ note: 'auto Base<T>::f(int) [with T = A]' 3 | auto f(int) { return static_cast<T*>(this); } | ^ Replacing "auto" with "T*", as well as invoking instance.f('x'), fixes the issue. clang compiles the code fine.