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: bad compile error #23912

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

gccgo: bad compile error #23912

dotaheor opened this issue Feb 18, 2018 · 4 comments
Milestone

Comments

@dotaheor
Copy link

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

gccgo (Debian 7.3.0-3) 7.3.0

What did you do?

package main

func main() {
	type E = struct{}
	type X struct{}
	var x X
	var y E = x // gccgo:  error: incompatible type in initialization (cannot use type X as type E)
	_ = y
}

What did you expect to see?

no problems to compile.

What did you see instead?

compile failed.

@gopherbot gopherbot added this to the Gccgo milestone Feb 18, 2018
@dotaheor
Copy link
Author

and this:

package main

func main() {
	type E = struct{}
	type S []E
	type T []struct{}
	type X struct{}
	var x X
	s := S{E{}}
	t := T{struct{}{}}
	_ = append(s, x) // gccgo:  argument 2 has incompatible type (cannot use type X as type E)
	_ = append(s, t[0])
	_ = append(s, t...)
}

@gopherbot
Copy link

Change https://golang.org/cl/94995 mentions this issue: test: add test case where gccgo incorrectly rejected aliases

@ianlancetaylor
Copy link
Contributor

Thanks for finding these cases.

@gopherbot
Copy link

Change https://golang.org/cl/94996 mentions this issue: compiler: look through aliases for type compatibility

gopherbot pushed a commit that referenced this issue Feb 20, 2018
Updates #23912

Change-Id: I50d06506a8ac91ed99a761a9ff3fd0b03d4c8121
Reviewed-on: https://go-review.googlesource.com/94995
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
hubot pushed a commit to gcc-mirror/gcc that referenced this issue Feb 20, 2018
    
    Aliases are supposed to be identical to the type being aliased, so
    questions about type compatibility need to always ignore aliases,
    except for error messages involving the type name.
    
    The test case for this is https://golang.org/cl/94995.
    
    Fixes golang/go#23912
    
    Reviewed-on: https://go-review.googlesource.com/94996


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257845 138bc75d-0d04-0410-961f-82ee72b054a4
@golang golang locked and limited conversation to collaborators Feb 20, 2019
asiekierka pushed a commit to WonderfulToolchain/gcc-ia16 that referenced this issue May 16, 2022
    
    Aliases are supposed to be identical to the type being aliased, so
    questions about type compatibility need to always ignore aliases,
    except for error messages involving the type name.
    
    The test case for this is https://golang.org/cl/94995.
    
    Fixes golang/go#23912
    
    Reviewed-on: https://go-review.googlesource.com/94996

From-SVN: r257845
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

3 participants