I found some interesting code lines:
It compiles ok (VS2013) and ends up in stackoverflow error because of the recursive call to
main(). I didn't know that the
return statement accepts any parameter that can be evaluated to the expected return data type, in this example even
Standard C or Microsoft-ish behaviour?
Best How To :
I didn't know that the return statement accepts any parameter that can be evaluated to the expected return data type,
return statement can have an expression.
C11 standard, chapter 220.127.116.11, The
return statement with an expression is executed, the value of the expression is returned to the caller as the value of the function call expression.
so, in case of
return main();, the
main(); function call is the expression.
And regarding the behaviour of
return main();, this behaves like a normal recursive function, the exception being an infinite recursion in this case.
C or Microsoft-ish behaviour?
As long as
C standard is considered, it does not impose any restriction upon calling
However, FWIW, AFAIK, in
C++, it is not allowed.