In Template Meta Programming if a recursion is wrongly implemented with a resulting infinite loop, can the language compiler detect it? Or will the compiler just encounter an eventual stack overflow and crashe? My bet would be that compiler cannot detect this because doing so would violate the undecideability of the halting problem.
Am I right with the conclusion? Of course I could try this out with a piece of code, but I would like to hear more qualified thinking in this case.
Edit : Thanks guys, I get a general idea that my inference on the computation theory aspect of tmp was not wrong. I also understand that compiler implementations can have arbitrary recursion depth limits(Of course I reiterate that I could have tested this second part, but it was only my side-point).
You are correct. Detecting an infinite recursion without limiting the recursion stack frames on template meta programming would mean finding an alternative solution to the halting problem.
There are a few special cases which are, in theory, detectable. For example, if you can ensure referential transparency on the recursion and if the last function call receives the same parameters as the actual one, you are on an infinite recursive call. C++ offers no referential transparency warranty on template meta programming.