Suppose we have the function :
void foo(int x)
{
foo(x);
}
on my machine (i7) will run approximately 260k times and generate segmentation fault. any idea why that happens ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Every time you call a function, it require space on the runtime stack. This is where variables local to that function have their memory allocated. What’s happening is that you’re recursing so many times that you’re running out of stack space — a stack overflow. (The name of this site!)
See also: http://en.wikipedia.org/wiki/Stack_overflow