Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.14.1 linux/amd64
and
$ go version go version go1.13.6 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go envGO111MODULE="auto" GOARCH="amd64" GOBIN="/home/user/Go/go/bin" GOCACHE="/home/user/.cache/go-build" GOENV="/home/user/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/user/Go/go" GOPRIVATE="" GOPROXY="direct" GOROOT="/home/user/Go/go-current" GOSUMDB="off" GOTMPDIR="" GOTOOLDIR="/home/user/Go/go-current/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" 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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build444610156=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Ran the following test program for both specified versions.
package main
import "testing"
// int -> complex
const constInt = 1
func TestConstInt(t *testing.T) {
_ = complex64(constInt)
}
const constIntExplicit = int(1)
func TestConstIntExplicit(t *testing.T) {
_ = complex64(constIntExplicit)
}
func TestVarInt(t *testing.T) {
varInt := 1
_ = complex64(varInt)
}
func TestVarIntExplicit(t *testing.T) {
varIntExplicit := int(1)
_ = complex64(varIntExplicit)
}
// float -> complex
const constFloat = 1.0
func TestConstFloat(t *testing.T) {
_ = complex64(constFloat)
}
const constFloatExplicit = float64(1.0)
func TestConstFloatExplicit(t *testing.T) {
_ = complex64(constFloatExplicit)
}
func TestVarFloat(t *testing.T) {
varFloat := 1.0
_ = complex64(varFloat)
}
func TestVarFloatExplicit(t *testing.T) {
varFloatExplicit := float64(1.0)
_ = complex64(varFloatExplicit)
}
What did you expect to see?
The test results to be the same for go version 1.13.6 and 1.14.1
What did you see instead?
Whereas both versions fail (correctly) when converting variable int/float to complex, they behave differently when converting typed constants to complex.
1.13.6 | 1.14.1 | |
---|---|---|
const int | y | y |
const int (explicit type) | y | n |
variable int | n | n |
variable int (explicit type) | n | n |
const float | y | y |
const float (explicit type) | y | n |
variable float | n | n |
variable float (explicit type) | n | n |
The results for go version 1.14.1 are the same for v1.14