golang/go

cmd/compile: compilation error: prepwrite: bad off=... siz=8 s=main..stmp_0

Closed

#78,974 opened on Apr 27, 2026

 (4 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (PR metrics pending)

Description

Go version

go version go1.27-devel_85f838f46c Sun Apr 26 20:38:08 2026 -0700 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='/research/compilers/gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build271633167=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/user/software/go/slot-a/src'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/user/software/go/slot-a/src/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.27-devel_85f838f46c Sun Apr 26 20:38:08 2026 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

$ go build /tmp/bug.go
# command-line-arguments
/tmp/bug.go:3:5: type [100000000000001]string larger than address space
/tmp/bug.go:3:5: prepwrite: bad off=1600000000000000 siz=8 s=main..stmp_0

$ cat /tmp/bug.go
package main

var expected = []string {
        100000000000000: "a",
}

func main() {}

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

What did you see happen?

$ go build /tmp/bug.go
# command-line-arguments
/tmp/bug.go:3:5: type [100000000000001]string larger than address space
/tmp/bug.go:3:5: prepwrite: bad off=1600000000000000 siz=8 s=main..stmp_0

What did you expect to see?

symbol too large error, a more specific compiler frontend error "index too large" or some dynamic handling.

I have spent some time trying to analyze if this is a known problem/wontfix. This has strong similarities to an old bug report https://github.com/golang/go/issues/23781 which had a non-global int array with a too large index and was eventually fixed (that issue's code compiles without crash for me).

I cannot get this bug to manifest with an int array, only with an array of strings where the string at the index is non-empty.

Contributor guide