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

main can't return int #688

Closed
brson opened this issue Jul 14, 2011 · 5 comments
Closed

main can't return int #688

brson opened this issue Jul 14, 2011 · 5 comments

Comments

@brson
Copy link
Contributor

brson commented Jul 14, 2011

When main is declared to return int, it always returns 0.

@graydon
Copy link
Contributor

graydon commented Jul 14, 2011

Well .. the program (properly: root task) returns zero. That's because the exit status is from the runtime, indicating presence or absence of failure (1 or 0 respectively) in the root task.

I suppose we can have "return nonzero" from main propagate out to the program return as well; but I'd like "fail" to continue to return nonzero from the root task as well.

@brson
Copy link
Contributor Author

brson commented Jul 14, 2011

Ah, that didn't occur to me. For my particular use case I just want to indicate failure anyway, so I actually don't need to return int. Maybe it's not necessary.

brson added a commit that referenced this issue Jul 14, 2011
This reverts commit 8c94d8f.

There's no mechanism to actually return the value from main, so all this does
is allow main -> int to compile. Per #688, the program returns non-zero on
failure, so it's not obvious that this change is appropriate at this time.
@msullivan
Copy link
Contributor

So should we close this?

@brson
Copy link
Contributor Author

brson commented Aug 12, 2011

Maybe we should at least make sure main has to return () so people don't get the impression they can return int

@msullivan
Copy link
Contributor

Closing this per discussion with brson. We can reopen it if we change our mind.

keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this issue Dec 12, 2017
Disable revocation checking temporarily on AppVeyor
ZuseZ4 added a commit to EnzymeAD/rust that referenced this issue Mar 7, 2023
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
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

3 participants