Andreas Schwab wrote:
Tobias Pflug <[EMAIL PROTECTED]> writes:

This will compile just fine. When compiled with -Wall it will at least
bring up a warning about the missing return statement in foo(), nothing
about main tho either. Or is there some standard that implicitly declares
main to return 0 when there is no explicit return statement?

If the return value of a function is never used then it is perfectly valid
to fall through the end of it.  For main, the default action is to return
0 since C99.

Andreas.


Well this might be, but the behavior of gcc does not change depending
on whether or not it is being used.

int foo() {}
int main() { foo(); }

^ No problem here


int foo() {}
int main
{ int test = foo();
  test++;
  printf("%d\n",test);
}

^ But this compiles without complaining as well. The result is random values for test.

That's not desirable is it ?

-Tobi

Reply via email to