]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.26] cmd/compile: avoid folding 64-bit integers into 32-bit constants
authorYoulin Feng <fengyoulin@live.com>
Sat, 14 Feb 2026 10:55:34 +0000 (18:55 +0800)
committerDavid Chase <drchase@google.com>
Wed, 25 Feb 2026 19:17:53 +0000 (11:17 -0800)
commit4659d630da3f96d3f463444057848f70d420bd0c
treef1be8613a4719beab70b4d198bf445c35e44f3ff
parent6fb3df88d48b27c384fc3bb11de6a6ebfdc4b9e4
[release-branch.go1.26] cmd/compile: avoid folding 64-bit integers into 32-bit constants

Folding a 64-bit integer into a 32-bit constant may result in a negative
integer if the value exceeds math.MaxInt32 (the maximum value of a 32-
bit signed integer). This negative value will be sign-extended to 64
bits at runtime, leading to unexpected results when used in bitwise
AND/OR operations.

Fixes #77618

Change-Id: Idb081a3c20c28bddddcc8eff1225d62123b37a2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/745581
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit 3c8b5e673816c733f13a38b1ed1f53d7d49ea084)
Reviewed-on: https://go-review.googlesource.com/c/go/+/745840
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
src/cmd/compile/internal/ssa/_gen/AMD64.rules
src/cmd/compile/internal/ssa/rewriteAMD64.go
test/fixedbugs/issue77613.go [new file with mode: 0644]