On Thu, Feb 02, 2012 at 10:55:06PM +0100, Timon Gehr wrote: > On 02/02/2012 08:04 PM, xancorreu wrote: [...] > >For the other hand, how can increase the stack in linux? [...] > > I don't know, but it is best to just rewrite the code so that it does > not use recursion. > > (This kind of problem is exactly the reason why any language standard > should mandate tail call optimization.)
Doesn't help badly-chosen implementations like: int fib(int n) { if (n <= 2) return 1; else return fib(n-2) + fib(n+1); } There's not much the compiler can do to offset programmers choosing the wrong algorithm for the job. It can't replace educating programmers to not implement things a certain way unless they have to. T -- Philosophy: how to make a career out of daydreaming.