cmd/vet, go/types: make it easier to handle architecture-dependent constant values correctly #11333
CL 11252 introduces a vet check for integer comparisons. It has false positives when checking code like
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?
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.