Skip to content

cmd/go: internal compiler error: assertion failed: on source consisting of {panic, declaration, label} #67661

Closed
@jfrech

Description

@jfrech

Go version

go version go1.22.1 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/jfrech/.cache/go-build'
GOENV='/home/jfrech/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/jfrech/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/jfrech/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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-build2525126656=/tmp/go-build -gno-record-gcc-switches'

What did you do?

With the following the contents of /tmp/ice.go (the Go playground rejects it as it doesn't vet):

package main

func main() {
	panic(0)

	x := 0

l:
	for {
		goto l
	}

	_ = x
}

I attempted compilation.

What did you see happen?

Attempting to compile lead to an internal compiler error:

$ go build /tmp/ice.go 
# command-line-arguments
CLOSURE [/tmp/ice.go:13:6:var x int]
<unknown line number>: internal compiler error: assertion failed

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

Fiddling with the panic's placement, the existence of a label and the existence of a declaration which is referenced after the label, only this combination yielded an internal compiler error.

What did you expect to see?

I want to get an executable which immediately panics, not a confused compiler's goodbye.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions