0
1
mirror of https://github.com/golang/go synced 2025-09-25 12:52:31 +00:00
Files
go/test/fixedbugs/issue75327.go
Keith Randall af03343f93 cmd/compile: fix bounds check report
For constant-index, variable length situations.

Inadvertant shadowing of the yVal variable. Oops.

Fixes #75327

Change-Id: I3403066fc39b7664222a3098cf0f22b5761ea66a
Reviewed-on: https://go-review.googlesource.com/c/go/+/702015
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-09 07:37:40 -07:00

34 lines
432 B
Go

// run
package main
import (
"fmt"
"strings"
)
func main() {
defer func() {
err := recover()
txt := fmt.Sprintf("%s", err)
if !strings.HasSuffix(txt, "with length 1") {
panic("bad error: " + txt)
}
}()
foo([]uint64{0})
}
//go:noinline
func foo(haystack []uint64) {
for n := range len(haystack) {
_ = n
_ = haystack[1]
}
xxx := haystack[0:len(haystack)]
sink(xxx)
}
//go:noinline
func sink([]uint64) {}