From 9fcb87c352b398aa650310160346c8d9bfcdcc45 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Tue, 12 Aug 2025 12:49:13 +0200 Subject: cmd/compile: teach prove about len's & cap's max based on the element size Change-Id: I88056fada1ff488c199fce54cf737dbdd091214d Reviewed-on: https://go-review.googlesource.com/c/go/+/695095 Auto-Submit: Jorropo LUCI-TryBot-Result: Go LUCI Reviewed-by: David Chase Reviewed-by: Keith Randall Reviewed-by: Keith Randall --- test/prove.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/prove.go b/test/prove.go index ef7690bbde..70a27865cf 100644 --- a/test/prove.go +++ b/test/prove.go @@ -2330,6 +2330,18 @@ func issue74473(s []uint) { } } +func setCapMaxBasedOnElementSize(x []uint64) int { + c := uintptr(cap(x)) + max := ^uintptr(0) >> 3 + if c > max { // ERROR "Disproved Less" + return 42 + } + if c <= max { // ERROR "Proved Leq" + return 1337 + } + return 0 +} + //go:noinline func useInt(a int) { } -- cgit v1.3-5-g9baa