From: Cuong Manh Le Date: Sat, 11 Apr 2020 14:49:10 +0000 (+0700) Subject: cmd/compile: correct comment for len check when make slice X-Git-Tag: go1.15beta1~592 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b78109e80e1dd5ff79001b2cefb2a0eff819422d;p=gostls13.git cmd/compile: correct comment for len check when make slice CL 226737 optimizes len check when make slice. The comment that cap is constrainted to [0, 2^31) is not quite true, it's 31 or 63 depends on whether it's 32/64-bit systems. Change-Id: I6f54e41827ffe4d0b67a44975da3ce07b2fabbad Reviewed-on: https://go-review.googlesource.com/c/go/+/227803 Run-TryBot: Cuong Manh Le TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index 57d71bf3d4..9eab170ddb 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -1352,7 +1352,8 @@ opswitch: Fatalf("walkexpr: invalid index %v", r) } - // cap is constrained to [0,2^31), so it's safe to do: + // cap is constrained to [0,2^31) or [0,2^63) depending on whether + // we're in 32-bit or 64-bit systems. So it's safe to do: // // if uint64(len) > cap { // if len < 0 { panicmakeslicelen() }