-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
flag: integer overflow in intValue.Set and uintValue.Set #19230
Comments
As an aside, your example program has a bug: You need to add the Yet, still, the issue is present. |
The code works correctly if you use |
@griesemer I don't think it is working as intended. The |
On Tue, Feb 21, 2017 at 11:16 PM, Robert Griesemer ***@***.*** > wrote:
The code works correctly if you use flag.Int64 instead:
https://play.golang.org/p/odbmwqKO3_ .
The problem is that intValue calls strconv.ParseInt(s, 0, 64).
It should call, instead, strconv.ParseInt(s, 0, strconv.IntSize)
See the discussion at
https://groups.google.com/forum/#!topic/golang-nuts/6rf8xh45m64
… Also, I believe you can define the how errors are handled explicitly:
https://golang.org/pkg/flag/#ErrorHandling. So this may actually be
working as intended.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#19230 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AF7dgGsflt_PNtDhFM5YNbXEY5LGrX3Eks5re2JAgaJpZM4MH6YT>
.
|
CL https://golang.org/cl/38419 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
What did you do?
I set a command line flag of type flag.Int, but with a value greater then 2^31 - 1 on 32 bit systems the underlying value is set to 0, instead of reporting an error.
Here is a sample program:
https://play.golang.org/p/F7YNWJWt29
flag.Uint has the same problem.
What did you expect to see?
The program should exit with an error status and message.
What did you see instead?
The program prints
System details
The text was updated successfully, but these errors were encountered: