You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is working as intended. The bug here is only that this was "unexpected", but rest assured that you can expect this. It's defined in the spec, implemented across multiple compilers, and tested thoroughly.
jid[5:] is a string of length 0. For a[low : high], the spec requires
0 <= low <= high <= len(a)
Note that every relation is a <=. In your case you have low = high (implied) = len(a) = 5, which is permitted. In jid[6:], on the other hand, low = 6 > len(a) = 5, which does not satisfy the relation above and is required to trigger a runtime error (and it does).
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.8.1
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kui/Downloads/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build932972831=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
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/80Xf0-hz6h
What did you expect to see?
string substring with index of string length should panic
What did you see instead?
string substring with index of string length does NOT fail, but stringLen + 1 fails.
The text was updated successfully, but these errors were encountered: