Problem Detail: Is C++ as a formal language recursively enumerable? If yes, is there any invalid C++ code that takes “infinite” time to compile?
Asked By : sai_preet
Answered By : Bartosz Przybylski
In theory this code should compile infinitely
template<long long K> struct t { enum { value = (K&1) ? t<K+1>::value : t<K-1>::value}; }; int main() { int i = t<1>::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.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/24381