https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96204
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- Reduced: template<typename...> using void_t = void; template<typename T> T&& declval(); template <typename, typename = void> struct has_set_attr_method { static constexpr bool value = false; }; template <typename T> struct has_set_attr_method<T, void_t<decltype(declval<T>().setAttr(1))>> { static constexpr bool value = true; }; struct Parent { public: template<typename T> static bool create() { return has_set_attr_method<T>::value; } }; struct Child : public Parent { public: friend class Parent; private: void setAttr(int) { } }; int main() { Parent::create<Child>(); }