https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104691
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- Reduced: template<typename T> typename T::foo f(T) { } template<typename T> typename T::bar f(T) { static_assert(false, ""); } struct X { using foo = void; }; int main() { X x; f(x); } All compilers reject this code. Something as simple as static_assert(sizeof(T) != 0, ""); can be used to make it dependent, and then it will only fail when the template is instantiated.