]> git.feebdaed.xyz Git - 0xmirror/go.git/commit
cmd/compile: fix mis-infer bounds in slice len/cap calculations
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 5 Dec 2025 14:49:53 +0000 (21:49 +0700)
committerGopher Robot <gobot@golang.org>
Fri, 5 Dec 2025 16:02:02 +0000 (08:02 -0800)
commitf84f8d86beb08631217e77d725a4b6528ed91dc2
treeb4eaae675d60d9cdb3484c648765a2669d45e585
parenta70addd3b31ccb685f48867e24c6c2b4dc364a11
cmd/compile: fix mis-infer bounds in slice len/cap calculations

CL 704875 enhanced prove to infer bounds when index have a relationship
with len(A) - K. However, the change incorrectly infer "K - len(A)" case,
causing wrong bounds information.

Fixing this by matching exactly "len(A) - K" case.

Fixes #76709

Change-Id: Ibeedff55520658401af5bd3aa7e98cc1bcf38fd6
Reviewed-on: https://go-review.googlesource.com/c/go/+/727180
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/ssa/prove.go
test/fixedbugs/issue76709.go [new file with mode: 0644]