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
x/tools/cmd/stringer: index out of range in generated code #10563
Labels
Comments
Proposed fix here: https://go-review.googlesource.com/9255 |
CL https://golang.org/cl/9255 mentions this issue. |
I can see that this issue had already been fixed. But yesterday, although I did a fresh |
SOF3
pushed a commit
to SOF3/go-stringer-inverse
that referenced
this issue
Aug 23, 2018
When String() was called on the maximum value of an integer type (eg 255 for uint8) this would cause an integer overflow, which would cause an index error later in the code. Fixed by re-arranging the code slightly. Fixes golang/go#10563 Change-Id: I9fd016afc5eea22adbc3843f6081091fd50deccf Reviewed-on: https://go-review.googlesource.com/9255 Reviewed-by: Rob Pike <r@golang.org>
SOF3
pushed a commit
to SOF3/go-stringer-inverse
that referenced
this issue
Aug 23, 2018
When String() was called on the maximum value of an integer type (eg 255 for uint8) this would cause an integer overflow, which would cause an index error later in the code. Fixed by re-arranging the code slightly. Fixes golang/go#10563 Change-Id: I9fd016afc5eea22adbc3843f6081091fd50deccf Reviewed-on: https://go-review.googlesource.com/9255 Reviewed-by: Rob Pike <r@golang.org>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Save this code to
stringerbug/main.go
Run
This produces the following panic
The offending code being that generated by stringer
Unfortunately adding 1 to i in the above has caused the integer to wrap. Rewriting to
Should fix it.
The text was updated successfully, but these errors were encountered: