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: crash when compiling code containing some type alias #24722

Closed
dotaheor opened this Issue Apr 6, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@dotaheor
Copy link

dotaheor commented Apr 6, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10.1 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

please view #24721 for details.

$ go build -compiler gccgo

What did you expect to see?

not crash

What did you see instead?

crash

@gopherbot gopherbot added this to the Gccgo milestone Apr 6, 2018

@tklauser

This comment has been minimized.

Copy link
Member

tklauser commented Apr 6, 2018

Reproducing program extracted from #24721:

package m3

import "time"

type t = time.Time
type T = time.Time

type A = struct{t}
type B = struct{T}
import "m3"
import "time"

type t = time.Time
type T = time.Time

type A = struct{t}
type B = struct{T}

func main() {
   var a, b interface{} = m3.A{}, m3.B{}
   var x, y interface{} = A{}, B{}
   println(a == x) // true
   println(b == y) // true
   
   _ = A(m3.A{}) // cannot convert struct { time.Time } literal (type struct { time.Time }) to type struct { time.Time }
   _ = B(m3.B{}) // ok
   
   println(a == b) // true
   println(x == y) // true
   _ = B(A{})       // cannot convert struct { time.Time } literal (type struct { time.Time }) to type struct { time.Time }
   _ = m3.A(m3.B{}) // cannot convert struct { time.Time } literal (type struct { time.Time }) to type struct { time.Time }
}

/cc @ianlancetaylor

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

ianlancetaylor commented Apr 18, 2018

@dotaheor Are you saying that for you gccgo crashes? It doesn't crash for me. Which version of gccgo are you running?

@dotaheor

This comment has been minimized.

Copy link
Author

dotaheor commented Apr 19, 2018

$ gccgo a.go
go1: internal compiler error: in write_specific_type_functions, at go/gofrontend/types.cc:2051
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.

$ gccgo --version
gccgo (Debian 7.3.0-3) 7.3.0
Copyright (C) 2017 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.

This command go run -compiler gccgo a.go also crashes.

Here is another simpler program for verifying.

package main

import (
	"fmt"
	"time"
)

type t = time.Time
type T = time.Time

type A = struct{ t }
type B = struct{ T }

func main() {
	var a A
	var b B
	fmt.Println(interface{}(b) == interface{}(a)) // true
	//fmt.Println(b == a)
}

BTW, the bug #24721 also exists for gccgo 7.3.0.

@dotaheor

This comment has been minimized.

Copy link
Author

dotaheor commented Apr 19, 2018

I just upgraded gccgo to gccgo (Debian 8-20180414-1) 8.0.1 20180414 (experimental) [trunk revision 259383], which doesn't crash, and it prints the right result. Cool!

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

ianlancetaylor commented Apr 19, 2018

Thanks for checking.

@golang golang locked and limited conversation to collaborators Apr 19, 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.