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, go/types: make it easier to handle architecture-dependent constant values correctly #11333

josharian opened this issue Jun 22, 2015 · 1 comment


Copy link

@josharian josharian commented Jun 22, 2015

CL 11252 introduces a vet check for integer comparisons. It has false positives when checking code like u > uint64(^uintptr(0)) where u is a uint64. This expression is always false when compiled for 64 bit machines but not for 32 bit machines. IIRC, something similar occurred for the suspicious shift vet check.

It would be nice if vet checks could inquire about types and values on a per-int-size basis.

go/types uses the host machine's integer size as a default. We could override that in vet and typecheck twice, once with 32 bit ints and once with 64 bit ints, but that would be expensive. Maybe there's a better way?

/cc @robpike @griesemer

@josharian josharian added this to the Unplanned milestone Jun 22, 2015
Copy link

@griesemer griesemer commented Jun 22, 2015

In general, such expressions can depend on other constant expressions (possibly via declared constants); some of the expressions are always true or false depending on platform. An easy way around type-checking twice is to provide a flag specifying the target platform (which we may not want). Otherwise I don't see an easy way around type-checking twice, and signaling an error only if it occurs for both platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants