https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89741
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- This needs to be verified by our C++ language lawyers, but if: "If no valid specialization can be generated for a template definition, and that template is not instantiated, the template definition is ill-formed, no diagnostic required." rule applies in this case, then what you are trying to do is not valid C++ and you'll need to find some other way, e.g. one where there are instantiations that could be instantiated. Say use template<typename T1, typename T2> struct Y { static constexpr bool value = false; }; template<> struct Y<void, void> { static constexpr bool value = true; }; template<> struct Y<void, float> { static constexpr bool value = true; }; template<int x, typename T, T y = 0> struct X { static_assert(Y<void, decltype(y)>::value, "1"); }; or something similar where all instantiations aren't invalid.