Skip to content

cmd/compile: Panic on compiling benchmark with reflection type switch #80801

Closed

Description

@nicholasngai

Go version

go version go1.26.5 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/nngai/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/nngai/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/0b/zx02r9711w3959xvwclcj99w0000gn/T/go-build2566178955=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/nngai/git/cel-jit/go.mod'
GOMODCACHE='/Users/nngai/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/nngai/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.26.5/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/nngai/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.26.5/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.26.5'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Attempted to run a simple benchmark:

package main

import (
	"reflect"
	"testing"
)

func BenchmarkReflect(b *testing.B) {
	for b.Loop() {
		s := any(int64(1))

		switch reflect.TypeOf(s) {
		case reflect.TypeFor[int64]():
		}
	}
}

What did you see happen?

# github.com/nicholasngai/cel-jit/test [github.com/nicholasngai/cel-jit/test.test]
/opt/homebrew/Cellar/go/1.26.5/libexec/src/iter/iter.go:223:6: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
FAIL	github.com/nicholasngai/cel-jit/test [build failed]
FAIL

What did you expect to see?

The benchmark runs.

Activity

  1. gopherbot commented on Aug 9, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/812580 mentions this issue: cmd/compile: avoid rewriting switch case expressions in b.Loop

  2. added
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Aug 11, 2026
  3. added this to the Go1.28 milestone on Aug 11, 2026
  4. added a commit that references this issue on Aug 11, 2026
    412d6e1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions