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/go: internal compiler error: OCONVIFACE can't operate on an empty interface #48279

Closed
rogpeppe opened this issue Sep 9, 2021 · 2 comments
Labels
FrozenDueToAge generics Issue is related to generics

Comments

@rogpeppe
Copy link
Contributor

rogpeppe commented Sep 9, 2021

go version devel go1.18-b86e8dd0f3 Thu Sep 9 09:06:46 2021 +0000 linux/amd64

This program crashes the current Go compiler:

package main

func main() {
	f[interface{}](nil)
}

func f[T any](x T) {
	var _ interface{} = x
}

Here's the panic traceback:

./tst.go:4:17: internal compiler error: OCONVIFACE can't operate on an empty interface

goroutine 1 [running]:
runtime/debug.Stack()
	/home/rogpeppe/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x1309a0, 0xc0}, {0xd1330d, 0x2e}, {0x0, 0x0, 0x0})
	/home/rogpeppe/go/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/base.Fatalf(...)
	/home/rogpeppe/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/walk.walkConvInterface(0xc000125950, 0xc000143a80)
	/home/rogpeppe/go/src/cmd/compile/internal/walk/convert.go:65 +0x155
cmd/compile/internal/walk.walkExpr1({0xe6b930, 0xc000125950}, 0xc000125950)
	/home/rogpeppe/go/src/cmd/compile/internal/walk/expr.go:211 +0x57f
cmd/compile/internal/walk.walkExpr({0xe6b930, 0xc000125950}, 0xc000143a80)
	/home/rogpeppe/go/src/cmd/compile/internal/walk/expr.go:55 +0x428
cmd/compile/internal/walk.walkAssign(0xc000143a80, {0xe6afd0, 0xc000125900})
	/home/rogpeppe/go/src/cmd/compile/internal/walk/assign.go:72 +0x9dc
cmd/compile/internal/walk.walkExpr1({0xe6afd0, 0xc000125900}, 0xc000125900)
	/home/rogpeppe/go/src/cmd/compile/internal/walk/expr.go:179 +0x43f
cmd/compile/internal/walk.walkExpr({0xe6afd0, 0xc000125900}, 0xc000143a80)
	/home/rogpeppe/go/src/cmd/compile/internal/walk/expr.go:55 +0x428
cmd/compile/internal/walk.walkStmt({0xe6afd0, 0xc000125900})
	/home/rogpeppe/go/src/cmd/compile/internal/walk/stmt.go:57 +0x5da
cmd/compile/internal/walk.walkStmtList({0xc00015a900, 0x7, 0xc00011e2c0})
	/home/rogpeppe/go/src/cmd/compile/internal/walk/stmt.go:167 +0x5b
cmd/compile/internal/walk.Walk(0xc00011e2c0)
	/home/rogpeppe/go/src/cmd/compile/internal/walk/walk.go:43 +0xef
cmd/compile/internal/gc.prepareFunc(0xc00011e2c0)
	/home/rogpeppe/go/src/cmd/compile/internal/gc/compile.go:92 +0x6d
cmd/compile/internal/gc.enqueueFunc(0xc00011e2c0)
	/home/rogpeppe/go/src/cmd/compile/internal/gc/compile.go:66 +0x2fd
cmd/compile/internal/gc.Main(0xd21e60)
	/home/rogpeppe/go/src/cmd/compile/internal/gc/main.go:303 +0xe94
main.main()
	/home/rogpeppe/go/src/cmd/compile/main.go:55 +0xdd

Seems like OCONVIFACE should be OK (or a no-op) in this case.

@rogpeppe rogpeppe added the generics Issue is related to generics label Sep 9, 2021
@cuonglm
Copy link
Member

cuonglm commented Sep 9, 2021

Seems duplicated of #48276

@randall77
Copy link
Contributor

Closing as dup.

@golang golang locked and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge generics Issue is related to generics
Projects
None yet
Development

No branches or pull requests

4 participants