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

cmd/compile: inconsistency between gc and gccgo #23913

Closed
dotaheor opened this issue Feb 18, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@dotaheor
Copy link

commented Feb 18, 2018

What version of Go are you using (go version)?

$ go version
go version go1.10 linux/amd64
$ gccgo --version
gccgo (Debian 7.3.0-3) 7.3.0

What did you do?

package main

func main() {
	type X = struct{}
	type Y struct{}
	type SX []X
	type SY []Y
	var x X
	var y Y
	sx := SX{X{}}
	sy := SY{Y{}}
	copy(sx, sy) // gc and gccgo both report error
	copy(sy, sx) // gc and gccgo both report error
	_ = append(sx, sy...) // gc and gccgo both report error
	_ = append(sy, sx...) // gc and gccgo both report error
	_ = append(sx, y) // only gccgo reports error
	_ = append(sy, x) // only gccgo reports error
}

What did you expect to see?

similar error output

What did you see instead?

gccgo reports two more errors for the last two lines.
I don't know which compiler is correct here.

@gopherbot gopherbot added this to the Gccgo milestone Feb 18, 2018

@dotaheor

This comment has been minimized.

Copy link
Author

commented Feb 18, 2018

I prefer to think this is a bug of gccgo, for gccgo is inconsistent to itself:

package main

func main() {
	type X = struct{}
	type Y struct{}
	type SY []Y
	sy := SY{Y{}}
	_ = append(sy, X{}) // gccgo: error: argument 2 has incompatible type (cannot use type X as type Y)
	_ = append(sy, struct{}{}) // gccgo: ok
}

Maybe it is the same bug as #23912

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Feb 18, 2018

Yes, this is the same as #23912. Closing as dup.

@golang golang locked and limited conversation to collaborators Feb 18, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.