Files
golang.go/test/fixedbugs/issue77613.go
Youlin Feng 3c8b5e6738 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 #77613

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>
2026-02-14 12:18:00 -08:00

29 lines
465 B
Go

// run
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"strings"
)
func main() {
str1 := "你好世界"
if !strings.HasSuffix(str1, "世界") {
panic(1)
}
str2 := "こんにちは"
if !strings.HasSuffix(str2, "ちは") {
panic(2)
}
str3 := "спасибо"
if !strings.HasSuffix(str3, "ибо") {
panic(3)
}
}