Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/vet: eliminate "might be too small" shift warnings #19321

Closed
josharian opened this issue Feb 28, 2017 · 2 comments
Closed

cmd/vet: eliminate "might be too small" shift warnings #19321

josharian opened this issue Feb 28, 2017 · 2 comments
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@josharian
Copy link
Contributor

func f(i int) int {
  return i >> 32
}

vet warns that i might be too small for a shift of 32. This happens for all machine-dependent types: int, uint, uintptr. This is a significant source of false positives in the standard library. We should instead look at the actual size on the platform being vetted, and complain definitively or not at all.

Related: #18085

cc @valyala @robpike

@josharian josharian added the Suggested Issues that may be good for new contributors looking for work to do. label Feb 28, 2017
@josharian josharian added this to the Go1.9 milestone Feb 28, 2017
@gopherbot
Copy link

CL https://golang.org/cl/37576 mentions this issue.

gopherbot pushed a commit that referenced this issue Feb 28, 2017
This is an inconsequential consequence of updating
math/big to use math/bits.

Better would be to teach the vet shift test
to size int/uint/uintptr to the platform in use,
eliminating the whole category of "might be too small".
Filed #19321 for that.

Change-Id: I7e0b837bd329132d7a564468c18502dd2e724fc6
Reviewed-on: https://go-review.googlesource.com/37576
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@gopherbot
Copy link

CL https://golang.org/cl/37950 mentions this issue.

@golang golang locked and limited conversation to collaborators Mar 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

2 participants