Go version

go version go1.22.5 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/root/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/root/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/bigdata/qiuhan/go1.22.5'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/bigdata/qiuhan/go1.22.5/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='/usr/bin/gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/bigdata/qiuhan/difftest/20240725_test_unit/d_2055/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build389564710=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Compile using the command go build main.go.

https://go.dev/play/p/EkHQBeM63VJ

package main

type Stringer interface {
    String() string
}

type (
    stringer  struct{}
    stringers [2]stringer
    foo       struct {
        stringers
    }
)

func (stringer) String() string  { return "" }
func toString(s Stringer) string { return s.String() }

func (v stringers) toStrings() []string {
    return []string{toString(v[0]), toString(v[1])}
}

func main() {
    _ = stringers{}
}

What did you see happen?

An internal compiler error occurred.

$ go build main.go
# 2055
<autogenerated>:1: internal compiler error: 'foo.toStrings': value v2 still has 1 uses

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

What did you expect to see?

Successful compilation of the program.

Comment From: gabyhelp

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: cuonglm

Likely duplicated of #65808

Comment From: randall77

Does that mean the fix for #65808 needs to be backported to 1.22? @dr2chase

Comment From: dr2chase

I just checked, it applies clean, and the test passes. And the fix itself is very low risk.

Comment From: gopherbot

Change https://go.dev/cl/601195 mentions this issue: [release-branch.go1.22] cmd/compile: add 0-sized-value simplification to copyelim

Comment From: dmitshur

Closing as duplicate of #65808.