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
This happens because bits.Len (and LeadingZeros, TrailingZeros, OnesCount) have return type int instead of uint. In the example given, this doesn't matter much because I can add the cast. But that's clutter and also adds to the inlining cost, despite the generated code being smaller.
It looks like the compiler knows that cap and len never return negative integers, so perhaps the math/bits functions could be dealt with in the same way?
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?
Reproduces with
What did you do?
What did you expect to see?
The same code as for
What did you see instead?
The compiler generates a check that boils down to
This happens because bits.Len (and LeadingZeros, TrailingZeros, OnesCount) have return type int instead of uint. In the example given, this doesn't matter much because I can add the cast. But that's clutter and also adds to the inlining cost, despite the generated code being smaller.
It looks like the compiler knows that cap and len never return negative integers, so perhaps the math/bits functions could be dealt with in the same way?
The text was updated successfully, but these errors were encountered: