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?