In either java or c I can write a function like
fun(){
fun();
}
(ignoring syntax details)
In java I get OutOfMemory exception but in C (and maybe some other languages) it seems to run forever, as if it were an infinite loop. Why don’t I get OutOfMemory error here as well?
Since your function is an example of tail recursion, then most likely, the C compiler is optimizing the recursion to iteration, causing it to loop infinitely without crashing.