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

go/types: constant LHS in non-constant shift used as index expression must fit into int #22969

Closed
griesemer opened this issue Dec 1, 2017 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

Per the spec, the following code

var a []int
var s uint
var _ = a[0xffffffffffffffff << s]

is not permitted:

  • the type of an untyped LHS in a non-constant shift is the type it would have without the shift
  • the type of an untyped constant index must be non-negative and representable by a value of type int

Here, 0xffffffffffffffff does not fit into an int, but go/types accepts it.

cmd/compile reports: constant 18446744073709551615 overflows int

@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 1, 2017
@griesemer griesemer added this to the Go1.11 milestone Dec 1, 2017
@griesemer griesemer self-assigned this Dec 1, 2017
@griesemer
Copy link
Contributor Author

Not urgent but the fix may be simple in which case we may want to do it for Go1.10.

@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Go1.12 Jun 29, 2018
@gopherbot
Copy link

Change https://golang.org/cl/144385 mentions this issue: go/types: untyped shifted constants must fit their expected int type

@golang golang locked and limited conversation to collaborators Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants