Is there C++ code that takes infinite time to compile?
In theory this code should compile infinitely

template&lt;long long K&gt;
struct t {
  enum { value = (K&amp;1) ? t&lt;K+1&gt;::value : t&lt;K-1&gt;::value};
};
int main() {
  int i = t&lt;1&gt;::value;
}


But in real life compilers are limiting template instantiation depth.
Another thing is that long long is limited so you cannot represent all integers.