int foo(int i) { if(i != 0) foo(i - 1); else return i; } GCC warns control reaches end of non-void function [-Wreturn-type].
Since the last return statement that set eax to 0, upon return from any other path, it returns 0. Also, compiler explorer produces the exact same code whether I wrote return foo(i - 1). Could one treat this as guaranteed behavior?
base case! That will have the "fall back" return statement compiler is looking for (since lookahead is limited, compiler cannot ascertain, when control will reach the return statement of your code).