https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81232
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ice-on-invalid-code Status|UNCONFIRMED |NEW Last reconfirmed| |2017-06-27 Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- GCC should not crash, but your code is invalid (and also crashes Clang): The problem is that you've defined the second overload with a non-deducible template parameter: template<int N, typename T> static constexpr T ipow(T x, int_<-1>) { return static_cast<T>(1) / ipow<-N>(x, int_<-N>()); } This cannot deduce N, so can only be called with a explicit argument, like ipow<-1> or ipow<-1, int>. That means when you call ipow(2, int_<-1>) you invoke the third overload, which recursively tries to call itself with more and more negative values of N, until the compiler dies.