Closed
Description
What version of Go are you using (go version
)?
go version go1.11 windows/amd64
What operating system and processor architecture are you using (go env
)?
set GOARCH=amd64
set GOBIN=
set GOCACHE=...
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=...
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=... -gno-record-gcc-switches
What did you do?
I compiled the following functions: https://play.golang.org/p/FstWIAwJwdg
What did you expect to see?
I expected two things:
- The test function to have bounds checking code, having in mind that a slice can have len == 0.
- When I run the program and enter 0 as input, the program should crash (because of index out of range) instead of returning me 0.
What did you see instead?
- The test function was compiled without bounds checking code.
- When I ran the program with input 0, everything went fine and 0 was printed to the console.