cmd/vet: unable to detect unreachable code #16370
Closed
Labels
Comments
I don't think we'd want vet to complain about such code. That's a fairly typical way to add debugging code, particularly in hot functions where you can't accept any runtime overhead when not debugging. |
It turns out that it is impossible to determine what code was eliminated? package main
const erraneous = (1 << 0) - 1
func main() {
if erraneous == 1 {
println("dead code")
}
} Code is silently eliminated by the compiler. And no warnings from vet. |
We try fairly strenuously to avoid flags. |
Working as intended, as @josharian explained. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Please answer these questions before submitting your issue. Thanks!
go version
)?go version go1.7rc1 windows/amd64
go env
)?set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:/work/go/
set GORACE=
set GOROOT=c:\go
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=c:\temp\go-build108228690=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1
go tool vet -unreachable main.go
a warning from vet
no warnings
The text was updated successfully, but these errors were encountered: