You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bounds checking because the index variable is signed.
While the result of LeadingZeros64 is signed, the compiler should know that the possible range is [0, 64] and deduce that n (and therefore i) will always be positive. (Even better would be using the result of LeadingZeros64 directly since the the n == 0 case reduces the range to [0, 63].)
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://go.dev/play/p/OZrfW7G5A6i
What did you expect to see?
No bounds checking for the array lookup in
B
.What did you see instead?
Bounds checking because the index variable is signed.
While the result of
LeadingZeros64
is signed, the compiler should know that the possible range is [0, 64] and deduce thatn
(and thereforei
) will always be positive. (Even better would be using the result ofLeadingZeros64
directly since the then == 0
case reduces the range to [0, 63].)The text was updated successfully, but these errors were encountered: