Closed tklauser closed 1 year ago
The problem is with inline static init, you can pass -d=inlstaticinit=0
to workaround this issue.
Change https://go.dev/cl/465096 mentions this issue: cmd/compile: fix inline static init for constant expression
@gopherbot please consider this for backport to 1.20, it's a regression.
Backport issue(s) opened: #58319 (for 1.20).
Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.
Change https://go.dev/cl/466277 mentions this issue: cmd/compile: rename EvalConst to EvalExpr
Change https://go.dev/cl/467015 mentions this issue: cmd/compile: disable inline static init optimization
Change https://go.dev/cl/467016 mentions this issue: cmd/compile: reenable inline static init
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, however it does not reproduce with Go 1.19 or earlier. So this looks like a regression in Go 1.20.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Some unit tests in the
github.com/cilium/cilium/cilium/cmd
package no longer built with a constant overflow error when being build with Go 1.20. They built fine and passed with Go 1.19 and earlier:https://github.com/cilium/cilium/actions/runs/4083992015/jobs/7040172384
@ti-mo managed to come up with a minimal reproducer:
https://go.dev/play/p/ClBVgMEVVhG?v=gotip
What did you expect to see?
The reproducer (and the tests in package
github.com/cilium/cilium/cmd
) to build without errors using Go 1.20.What did you see instead?
The error only seems to occur if the result of
bits.ReverseBytes16(13579)
is assigned to a package level var. It builds fine if the result is assigned e.g. to a func level var.Thanks to @ti-mo for helping me analyze this error and coming up with a minimal reproducer for playground.