Closed
Description
Please answer these questions before submitting your issue. Thanks!
What did you do?
Hello up there, please consider the following relatively-minimal snippet:
package xxx
type NodeLink struct {}
// A role our end of NodeLink is intended to play
type LinkRole int
const (
LinkServer LinkRole = iota // link created as server
LinkClient // link created as client
// for testing:
linkNoRecvSend LinkRole = 1<<16 // do not spawn serveRecv & serveSend
linkFlagsMask LinkRole = (1<<32 - 1) << 16
)
func NewNodeLink(role LinkRole) *NodeLink {
var nextConnId uint32
switch role&^linkFlagsMask {
case LinkServer:
nextConnId = 0 // all initiated by us connId will be even
case LinkClient:
nextConnId = 1 // ----//---- odd
default:
panic("invalid conn role")
}
_ = nextConnId
return nil
}
(https://play.golang.org/p/QJn8WazIMx)
What did you expect to see?
This code compiles ok.
What did you see instead?
kirr@deco:~/tmp/trashme/t/testq$ go tool compile connection.go
connection.go:24:8: invalid instruction: 00047 (connection.go:19) TESTQ $-281474976645121, CX
Does this issue reproduce with the latest release (go1.8)?
No, it is a regression:
kirr@deco:~/tmp/trashme/t/testq$ go18 tool compile connection.go
kirr@deco:~/tmp/trashme/t/testq$ echo $?
0
System details
go version devel +43afcb5c96 Wed Mar 15 04:27:49 2017 +0000 linux/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kirr/go"
GORACE=""
GOROOT="/home/kirr/src/tools/go/go"
GOTOOLDIR="/home/kirr/src/tools/go/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build190602604=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOROOT/bin/go version: go version devel +43afcb5c96 Wed Mar 15 04:27:49 2017 +0000 linux/amd64
GOROOT/bin/go tool compile -V: compile version devel +43afcb5c96 Wed Mar 15 04:27:49 2017 +0000 X:framepointer
uname -sr: Linux 4.9.0-2-amd64
Distributor ID: Debian
Description: Debian GNU/Linux 9.0 (stretch)
Release: 9.0
Codename: stretch
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Debian GLIBC 2.24-9) stable release version 2.24, by Roland McGrath et al.
gdb --version: GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Thanks beforehand,
Kirill
/cc @rasky