gccgo: does not convert untyped complex 0i to int in binary operation involving an int
dvyukov opened this issue · 3 comments
dvyukov commented
gc successfully compiles the following program:
package a
var e,f = f^0i,0
while gccgo says:
go.go:2:12: error: incompatible types in binary expression
gccgo seems to be right, because 0i is imaginary literal.
go version devel +bb7e665 Tue Jun 30 07:42:37 2015 +0000 linux/amd64
dvyukov commented
griesemer commented
This is a gccgo bug. 0i is a unyped complex constant that can be accurately represented as an int. The declaration is evaluated as follows:
var f = 0 // f is of type int
var e = f^0i // e is of type int, 0i is converted to int
http://play.golang.org/p/d2-k9sg21l
Both gc and go/types agree.
ianlancetaylor commented
This works on tip now, although I don't know when it was fixed.