Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccgo: does not convert untyped complex 0i to int in binary operation involving an int #11563

Closed
dvyukov opened this issue Jul 3, 2015 · 3 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Jul 3, 2015

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
Copy link
Member Author

dvyukov commented Jul 3, 2015

@iant @gri @paranoiacblack

@griesemer
Copy link
Contributor

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.

@griesemer griesemer changed the title cmd/compile: treats complex constant as integer gccgo: does not convert untyped complex 0i to int in binary operation involving an int Jul 3, 2015
@griesemer griesemer assigned paranoiacblack and unassigned rsc Jul 3, 2015
@ianlancetaylor ianlancetaylor added this to the Gccgo milestone Jul 10, 2015
@bradfitz bradfitz removed the Started label Jan 6, 2017
@ianlancetaylor
Copy link
Contributor

This works on tip now, although I don't know when it was fixed.

@golang golang locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants