see What and where are the stack and heap?
You'll get a stack overflow pretty quickly if you produce a function that calls itself endlessly. Each function call will take up space on the stack, and you will run out of stack space very quickly!
void f()
{
f();
}
In Visual Studio 2012, this code even produced a warning
warning C4717: 'f' : recursive on all control paths, function will cause runtime stack overflow
The function didn't get optimized out on Visual Studio 2012, but nevertheless, as @MooingDuck points out, compilers can be rather clever at spotting optimizations and potential errors in code.
Tell-tale sign of a stack overflow is seeing the same function repeated over and over in your call stack in your program when your program crashes! Probably better to see how it looks now so you now how to recognize it in future...