-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: constant overflows when assigned to package level var (Go 1.20 regression) #58293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The problem is with inline static init, you can pass |
Change https://go.dev/cl/465096 mentions this issue: |
@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. |
….20.0" This reverts commit 80de240. The Golang v1.20.0 release includes a regression [1]. We should wait for a new patch release before updating. 1 - golang/go#58293 Reported-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Paul Chaignon <paul@cilium.io>
….20.0" This reverts commit 80de240. The Golang v1.20.0 release includes a regression [1]. We should wait for a new patch release before updating. 1 - golang/go#58293 Reported-by: Tobias Klauser <tobias@cilium.io> Signed-off-by: Paul Chaignon <paul@cilium.io>
Change https://go.dev/cl/466277 mentions this issue: |
Change https://go.dev/cl/467015 mentions this issue: |
Change https://go.dev/cl/467016 mentions this issue: |
There are a plenty of regression in 1.20 with this optimization. This CL disable inline static init, so it's safer to backport to 1.20 branch. The optimization will be enabled again during 1.21 cycle. Updates #58293 Updates #58339 For #58293 Change-Id: If5916008597b46146b4dc7108c6b389d53f35e95 Reviewed-on: https://go-review.googlesource.com/c/go/+/467015 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Since go1.19, these errors are already reported by types2 for any user's Go code. Compiler generated code, which looks like constant expression should be evaluated as non-constant semantic, which allows overflows. Fixes golang#58293 Change-Id: I6f0049a69bdb0a8d0d7a0db49c7badaa92598ea2 Reviewed-on: https://go-review.googlesource.com/c/go/+/465096 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
There are a plenty of regression in 1.20 with this optimization. This CL disable inline static init, so it's safer to backport to 1.20 branch. The optimization will be enabled again during 1.21 cycle. Updates golang#58293 Updates golang#58339 For golang#58293 Change-Id: If5916008597b46146b4dc7108c6b389d53f35e95 Reviewed-on: https://go-review.googlesource.com/c/go/+/467015 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Static init inliner is using typecheck.EvalConst to handle string concatenation expressions. But static init inliner may reveal constant expressions after substitution, and the compiler needs to evaluate those expressions in non-constant semantic. Using typecheck.EvalConst, which always evaluates expressions in constant semantic, is not the right choice. For safety, this CL fold the logic to handle string concatenation to static init inliner, so there won't be regression in handling constant expressions in non-constant semantic. And also, future CL can simplify typecheck.EvalConst logic. Updates #58293 Updates #58339 Fixes #58439 Change-Id: I74068d99c245938e576afe9460cbd2b39677bbff Reviewed-on: https://go-review.googlesource.com/c/go/+/466277 Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Updates #58293 Updates #58339 Fixes #58439 Change-Id: I06d2d92f86fa4a672d69515c4066d69d3e0fc75b Reviewed-on: https://go-review.googlesource.com/c/go/+/467016 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
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.
The text was updated successfully, but these errors were encountered: