Skip to content

cmd/compile: walkConvInterface produces broken IR  #56768

Closed

Description

@cuonglm

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

$ go version
go version devel go1.20-b1678e508b Wed Nov 16 04:04:52 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

Compile following program:

package p

type I interface {
	M()
}

type S struct{}

func (*S) M() {}

type slice []any

func f() {
	ss := struct {
		i I
	}{
		i: &S{},
	}

	_ = [...]struct {
		s slice
	}{
		{
			s: slice{ss.i},
		},
		{
			s: slice{ss.i},
		},
		{
			s: slice{ss.i},
		},
		{
			s: slice{ss.i},
		},
		{
			s: slice{ss.i},
		},
	}
}

What did you expect to see?

Compile ok.

What did you see instead?

/home/cuonglm/p.go:30:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:33:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:36:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:39:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:42:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment

The fix for #56727 reveals this bug, because it called typecheck on walked IR.

The problem is in walkConvInterface, we generate code like:

var typeWord *uint8
typeWord = itab

But itab has type *uintptr. I think we can just switch itab to *uint8 (any generic pointer type should work, I guess) cc @randall77

Activity

  1. self-assigned this
    on Nov 16, 2022
  2. added this to the Go1.20 milestone on Nov 16, 2022
  3. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Nov 16, 2022
  4. gopherbot commented on Nov 16, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/451256 mentions this issue: cmd/compile: fix broken IR for iface -> eface

  5. cuonglm commented on Nov 16, 2022

    @cuonglm
    MemberAuthor

    @gopherbot please backport this to go1.19

  6. gopherbot commented on Nov 16, 2022

    @gopherbot
    Contributor

    Backport issue(s) opened: #56770 (for 1.19).

    Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

  7. locked and limited conversation to collaborators on Nov 23, 2023
  8. added a commit that references this issue on Feb 20, 2024
    81c9b1d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions