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: crash with generic function call #45547

griesemer opened this issue Apr 13, 2021 · 1 comment

cmd/compile: crash with generic function call #45547

griesemer opened this issue Apr 13, 2021 · 1 comment


Copy link

@griesemer griesemer commented Apr 13, 2021

The following program crashes the compiler:

package p

func f[T any]() (f, g T) { return f, g }

func _() {
	var _, _ = f[int]()  // THIS IS OK

var _, _ = f[int]() // <<< CULPRIT

The top-level variable declaration is the culprit.

$ go tool compile -G=3 test.go
esc [0xc000320360]
.   CALL tc(1) Use:2 STRUCT-(int, int) # test.go:9 STRUCT-(int, int)
.   .   FUNCINST tc(1) FUNC-func[T₁]() (T₁, T₁) # test.go:9 FUNC-func[T₁]() (T₁, T₁)
.   .   .   NAME-p.f tc(1) Class:PFUNC Offset:0 FUNC-func[T₁]() (T₁, T₁) # test.go:3
.   .   FUNCINST-Targs
.   .   .   TYPE .int Offset:0 type int
test.go:9:5: internal compiler error: unexpected call op: function call

goroutine 1 [running]:
runtime/debug.Stack(0x1ba30c0, 0xc0000b6008, 0x0)
	/Users/gri/goroot/src/runtime/debug/stack.go:24 +0x9f
cmd/compile/internal/base.FatalfAt(0x905000000002, 0x1a60349, 0x16, 0xc0000cd598, 0x1, 0x1)
	/Users/gri/goroot/src/cmd/compile/internal/base/print.go:227 +0x1ea
cmd/compile/internal/escape.(*escape).call(0xc0000eef40, 0xc0000bbdc0, 0x2, 0x2, 0x1bb66b8, 0xc000320360, 0x0, 0x0)
	/Users/gri/goroot/src/cmd/compile/internal/escape/escape.go:1006 +0xd2a
cmd/compile/internal/escape.(*escape).stmt(0xc0000eef40, 0x1bb6140, 0xc000386a80)
	/Users/gri/goroot/src/cmd/compile/internal/escape/escape.go:524 +0x1105
cmd/compile/internal/escape.(*escape).stmts(0xc0000eef40, 0xc000096a80, 0x1, 0x1)
	/Users/gri/goroot/src/cmd/compile/internal/escape/escape.go:548 +0x72
cmd/compile/internal/escape.(*escape).block(0xc0000eef40, 0xc000096a80, 0x1, 0x1)
	/Users/gri/goroot/src/cmd/compile/internal/escape/escape.go:555 +0x52
cmd/compile/internal/escape.(*batch).walkFunc(0xc000323560, 0xc0000fa6e0)
	/Users/gri/goroot/src/cmd/compile/internal/escape/escape.go:307 +0x117
cmd/compile/internal/escape.Batch(0xc000096d50, 0x1, 0x2, 0xc000383900)
	/Users/gri/goroot/src/cmd/compile/internal/escape/escape.go:229 +0x23b
cmd/compile/internal/ir.(*bottomUpVisitor).visit(0xc000388750, 0xc0000fa6e0, 0xc015914700000004)
	/Users/gri/goroot/src/cmd/compile/internal/ir/scc.go:128 +0x392
cmd/compile/internal/ir.VisitFuncsBottomUp(0xc000386ae0, 0x4, 0x6, 0x1a80178)
	/Users/gri/goroot/src/cmd/compile/internal/ir/scc.go:60 +0x11a
	/Users/gri/goroot/src/cmd/compile/internal/gc/main.go:252 +0xeff
	/Users/gri/goroot/src/cmd/compile/main.go:54 +0x155
Copy link

@gopherbot gopherbot commented Apr 14, 2021

Change mentions this issue: cmd/compile: look for function in instantiations in all global assignments


@gopherbot gopherbot closed this in bf634c7 Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants