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

strconv: define integer return value in case of error in ParseInt #7105

Closed
dominikh opened this issue Jan 11, 2014 · 3 comments
Closed

strconv: define integer return value in case of error in ParseInt #7105

dominikh opened this issue Jan 11, 2014 · 3 comments
Milestone

Comments

@dominikh
Copy link
Member

Usually, when a function returns an error, its other return values are considered
undefined. The current implementation of strconv.ParseInt, however, makes sure to return
meaningful values even in error cases. For format errors, it always returns 0 instead of
leaking parser state, and for overflow it returns the biggest/smallest possible value
and preserves the sign, as opposed to just wrapping around or behaving in other
unexpected ways.

These attributes can simplify code at the caller site, but only if they are documented
and guaranteed to stay in future versions and other implementations of the standard
library.

If they are in fact intended parts of the API, they should be documented as such.
@griesemer
Copy link
Contributor

Comment 1:

Labels changed: added repo-main.

@bradfitz
Copy link
Contributor

Comment 2:

Labels changed: added release-go1.3.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Mar 7, 2014

Comment 3:

This issue was closed by revision c0d4576.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants