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: internal compiler error for (invalid) program using interface aliases #25302

Closed
griesemer opened this issue May 8, 2018 · 4 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@griesemer
Copy link
Contributor

$ gccgo --version
gccgo (google-gccgo-257955) 8.0.1 20180223 (experimental)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cat x.go
package main

type T = interface {
	m() interface{ T }
}

type S struct{}

func (S) m() interface{ T } {
	return nil
}

func main() {
	var s S
	var t T = s
	t.m()
}
$ gccgo x.go
gccgo: internal compiler error: Segmentation fault signal terminated program go1
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://go.ext.google.com/go/> for instructions.

For reference:
cmd/compile reports:

x.go:3:6: invalid recursive type alias T
	x.go:3:6: T uses <T>
	x.go:3:10: <T> uses <T>
	x.go:4:3: <T> uses <T>
	x.go:4:6: <T> uses T

go/types reports (incorrectly - see issue #25301 ):

x.go:9:25: invalid AST: T is not a named type
x.go:4:17: invalid AST: T is not a named type
x.go:4:17: invalid AST: T is not a named type

The following code:

package main

type T = interface {
	m() interface{ T }
}

func main() {
}

is silently accepted by gccgo, but the embedded interface T cannot be "expanded out". We don't specify this in the spec (yet), but it's one of the limitations we have for type aliases, at least according to the design doc.

@griesemer griesemer added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 8, 2018
@griesemer griesemer added this to the Gccgo milestone May 8, 2018
@ianlancetaylor
Copy link
Contributor

CC @thanm

@thanm
Copy link
Contributor

thanm commented May 9, 2018

I'll take a look later today.

@benshi001
Copy link
Member

Though this issue has the same root cause as #25851, different solutions are needed. We should rise an error like "recursive interface alias" for this issue, and generate right code for #25851.

@gopherbot
Copy link

Change https://golang.org/cl/163298 mentions this issue: compiler: traverse inherited interface aliases

kraj pushed a commit to kraj/gcc that referenced this issue Feb 27, 2019
    
    Fixes golang/go#25302.
    
    Reviewed-on: https://go-review.googlesource.com/c/163298


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269241 138bc75d-0d04-0410-961f-82ee72b054a4
@golang golang locked and limited conversation to collaborators Feb 27, 2020
@rsc rsc unassigned thanm Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants