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

Comments

Projects
None yet
2 participants
@josharian
Contributor

josharian commented Feb 28, 2017

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 label Feb 28, 2017

@josharian josharian added this to the Go1.9 milestone Feb 28, 2017

@gopherbot

This comment has been minimized.

gopherbot commented Feb 28, 2017

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

gopherbot pushed a commit that referenced this issue Feb 28, 2017

cmd/vet/all: move suspicious shift whitelists to 64 bit
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

This comment has been minimized.

gopherbot commented Mar 8, 2017

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

@gopherbot gopherbot closed this in 6bc5938 Mar 11, 2017

@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.