https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61174
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> --- Instead of starting from scratch, why don't you use std::is_member_function_pointer? It handles correctly all sorts of member functions. Alternately, study the implementation and learn from it. In any case, you have of course a problem with the constness of g, you would have to add: template<typename C, typename T> struct A<T (C::*)() const> { int ok; }; because otherwise the first specialization - as you can easily learn from <type_traits> - matches f and all sorts of member pointers, for that matter.