void g(auto x) { g(x - 1); }
Absence of declared type for the argument of the function.
Absence of any means of stopping the recursion.
Absence of any context.
Probably an infinite loop.
g(2) call g(1)
g(1) call g(0)
g(0) call g(-1) etc...
You should put something like this :
Last edited on
I got
test.cpp:1:8: warning: use of 'auto' in parameter declaration only available with -fconcepts
void g(auto x) { g(x - 1); } |
Go on, stick the line
g(10);
in the middle of int main() and find out how big the stack is(n't).
Last edited on
Well funny you should mention that, if you compile with -O3, I believe g++ does tail-call optimization, and it doesn't crash for me.
But even without a stack overflow, the program will have undefined behavior once x - 1 underflows after being the lowest int possible.