Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing return statement from func declared as returning int. #85

Closed
sgbeal opened this issue Jun 28, 2018 · 4 comments
Closed

Missing return statement from func declared as returning int. #85

sgbeal opened this issue Jun 28, 2018 · 4 comments

Comments

@sgbeal
Copy link

sgbeal commented Jun 28, 2018

In my experience, only MS compilers won't complain about a missing return.

@sgbeal
Copy link
Author

sgbeal commented Jun 28, 2018

@sgbeal
Copy link
Author

sgbeal commented Jun 28, 2018

@isaacbrodsky
Copy link
Collaborator

Hi, I just checked using GCC 6 and do not see any errors or warnings. Looking this up online, it looks like the C99 standard permits not explicitly returning from int main. See for example: https://stackoverflow.com/questions/3727051/why-does-a-main-function-without-a-return-statement-return-value-12/3728153#3728153 Do you have an example compiler/version that's able to compile the example but warns or doesn't emit the return 0?

I don't think there'd be an objection to adding an explicit return statement if you'd like to open a PR.

@sgbeal
Copy link
Author

sgbeal commented Jun 28, 2018

i didn't attempt compilation - just eyeballed the code (and it failed that compilation check ;)). Adding an explicit return for a function declared as returning a value is simply The Right Thing To Do, main() or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants