Skip to content

Incorrect slice indexing doesn't panic #27466

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

Closed
ofw opened this issue Sep 3, 2018 · 1 comment
Closed

Incorrect slice indexing doesn't panic #27466

ofw opened this issue Sep 3, 2018 · 1 comment

Comments

@ofw
Copy link

ofw commented Sep 3, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using?

go1.11 darwin/amd64

Does this issue reproduce with the latest release?

yes. It is reproduced only with go 1.11

What operating system and processor architecture are you using?

GOARCH="amd64"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n3/mmrp5zqs4l32jk1bnxghymkh0000gn/T/go-build253851043=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

package main

import "fmt"

func main() {
	slice := make([]int, 0)
	if len(slice) > 10 {
		slice = append(slice, 1)
	}
	fmt.Println(slice[len(slice)-1])
}

What did you expect to see?

panic: runtime error: index out of range

goroutine 1 [running]:
main.main()
	/tmp/sandbox394962805/main.go:10 +0x20

What did you see instead?

0

Process finished with exit code 0
@ofw ofw changed the title Incorrect slice indexing doesn't panics Incorrect slice indexing doesn't panic Sep 3, 2018
@ofw
Copy link
Author

ofw commented Sep 3, 2018

duplicates #27378

@ofw ofw closed this as completed Sep 3, 2018
@golang golang locked and limited conversation to collaborators Sep 3, 2019
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

2 participants