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: int overflow in switch expression #11667

Closed
dvyukov opened this issue Jul 11, 2015 · 3 comments
Closed

go/types: int overflow in switch expression #11667

dvyukov opened this issue Jul 11, 2015 · 3 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Jul 11, 2015

gotype successfully compiles the following program:

package a
func f() {
    switch 9223372036854775808 {
    }
}

gc rejects it with:

go.go:3: constant 9223372036854775808 overflows int

gc seems to be right.

on commit af81789

@dvyukov
Copy link
Member Author

dvyukov commented Jul 11, 2015

The same happens in switch cases as well:

package a
func f() {
    switch 9223372036854775808 {
    case 9223372036854775808:
    }
}

@griesemer griesemer added this to the Go1.6 milestone Jul 11, 2015
@griesemer
Copy link
Contributor

The switch statement is actually underspecified in this respect. It does not say that the switch expression has to fit into a basic type. So technically, I believe gotype is correct. That said, I think the spec needs to be clarified as the current situation is not tenable in general. Leaving as go/types bug.

@gopherbot
Copy link
Contributor

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

@griesemer griesemer changed the title x/tools/go/types: int overflow in switch expression go/types: int overflow in switch expression Jul 31, 2015
@golang golang locked and limited conversation to collaborators Aug 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants