Skip to content

cmd/compile: runtime panic due to bad devirtualization #43292

@mdempsky

Description

@mdempsky

This program should run without crashing, but currently panics at tip:

package main

type I interface { M() chan int }

type A int
func (A) M() chan int { return nil }

type B int
func (B) M() chan int { return nil }

func main() {
	c := I(A(0))

	b := make(chan I, 1)
	b <- B(0)

	for i := 0; i < 2; i++ {
		select {
		case c = <-b:
		case <-c.M():
		default:
		}
	}
}

Based on test case reported by @kivikakk in #42284.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions