-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
panic: runtime error: index out of range in for statement with an uint64 typed i #17940
Comments
The following is broken:
(Note that you declared |
Replace the for loop with the below code to fix this usage issue.
|
This is not a bug.
https://tip.golang.org/ref/spec#Variable_declarations There is nothing special about assignments found in for statements. Your expression has a type because size has a type.
|
@g0hacker Let's take discussion about the language to a forum, not the issue tracker. See https://golang.org/wiki/Questions . Thanks. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7.3 darwin/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN="/Users/haolin/Gobin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/haolin/Projects/gopcp.v2"
GORACE=""
GOROOT="/usr/local/go1.7"
GOTOOLDIR="/usr/local/go1.7/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ts/7lg_tl_x2gd_k1lm5g_48c7w0000gn/T/go-build893809424=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
https://play.golang.org/p/8EjmBiJS1h
What did you expect to see?
It run without any error.
What did you see instead?
panic: runtime error: index out of range
goroutine 1 [running]:
panic(0x90ea0, 0xc42000a0f0)
/usr/local/go1.7/src/runtime/panic.go:500 +0x1a1
main.main()
/Users/haolin/demo.go:10 +0x1c1
exit status 2
Update: That's my fault. I am sorry to interrupt. My brain was imprisoned. ;-)
The text was updated successfully, but these errors were encountered: